@leonxin/meetgames 0.1.18 → 0.1.19

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 (88) hide show
  1. package/README.md +5 -4
  2. package/dist/cache.d.ts +16 -0
  3. package/dist/cache.d.ts.map +1 -1
  4. package/dist/cache.js +21 -0
  5. package/dist/cache.js.map +1 -1
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +20 -16
  8. package/dist/cli.js.map +1 -1
  9. package/dist/config/meetSdkDefaultConfig.d.ts +7 -11
  10. package/dist/config/meetSdkDefaultConfig.d.ts.map +1 -1
  11. package/dist/config/meetSdkDefaultConfig.js +216 -53
  12. package/dist/config/meetSdkDefaultConfig.js.map +1 -1
  13. package/dist/config/meetSdkIosConfig.d.ts +4 -5
  14. package/dist/config/meetSdkIosConfig.d.ts.map +1 -1
  15. package/dist/config/meetSdkIosConfig.js +19 -19
  16. package/dist/config/meetSdkIosConfig.js.map +1 -1
  17. package/dist/contracts/types.d.ts +4 -0
  18. package/dist/contracts/types.d.ts.map +1 -1
  19. package/dist/core/doctor.d.ts.map +1 -1
  20. package/dist/core/doctor.js +2 -0
  21. package/dist/core/doctor.js.map +1 -1
  22. package/dist/core/previewPatches.d.ts +2 -2
  23. package/dist/core/previewPatches.d.ts.map +1 -1
  24. package/dist/core/previewPatches.js +3 -3
  25. package/dist/core/previewPatches.js.map +1 -1
  26. package/dist/core/workspace.d.ts.map +1 -1
  27. package/dist/core/workspace.js +1 -0
  28. package/dist/core/workspace.js.map +1 -1
  29. package/dist/index.d.ts +4 -4
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +4 -4
  32. package/dist/index.js.map +1 -1
  33. package/dist/mcp/service.d.ts +2 -0
  34. package/dist/mcp/service.d.ts.map +1 -1
  35. package/dist/mcp/service.js +8 -7
  36. package/dist/mcp/service.js.map +1 -1
  37. package/dist/ops/handlers.d.ts.map +1 -1
  38. package/dist/ops/handlers.js +4 -0
  39. package/dist/ops/handlers.js.map +1 -1
  40. package/dist/remote/sdkHomeDownload.d.ts +4 -5
  41. package/dist/remote/sdkHomeDownload.d.ts.map +1 -1
  42. package/dist/remote/sdkHomeDownload.js +38 -12
  43. package/dist/remote/sdkHomeDownload.js.map +1 -1
  44. package/docs/API.md +13 -13
  45. package/docs/CLI.md +27 -13
  46. package/docs/INTEGRATION.md +7 -6
  47. package/package.json +1 -1
  48. package/src/cache.ts +37 -0
  49. package/src/cli.ts +21 -14
  50. package/src/config/meetSdkDefaultConfig.ts +243 -59
  51. package/src/config/meetSdkIosConfig.ts +17 -21
  52. package/src/contracts/types.ts +4 -0
  53. package/src/core/doctor.ts +2 -0
  54. package/src/core/previewPatches.ts +3 -3
  55. package/src/core/workspace.ts +1 -0
  56. package/src/index.ts +5 -3
  57. package/src/mcp/service.ts +11 -7
  58. package/src/ops/handlers.ts +4 -0
  59. package/src/remote/sdkHomeDownload.ts +48 -16
  60. package/config/meetsdk-android.json +0 -171
  61. package/config/meetsdk-ios.json +0 -15
  62. package/tests/assemble.test.ts +0 -12
  63. package/tests/doctor.test.ts +0 -131
  64. package/tests/downloadGoogleServicesJson.test.ts +0 -47
  65. package/tests/fetch-remote.test.ts +0 -23
  66. package/tests/fetchConfigOverrides.test.ts +0 -28
  67. package/tests/fetchConfigWrite.test.ts +0 -54
  68. package/tests/fixtures-hosts.test.ts +0 -78
  69. package/tests/gradle.test.ts +0 -33
  70. package/tests/integration-json.test.ts +0 -29
  71. package/tests/ios.codeUtils.test.ts +0 -23
  72. package/tests/ios.sdkBundle.test.ts +0 -21
  73. package/tests/loadManifest.test.ts +0 -15
  74. package/tests/manifest-xml.test.ts +0 -30
  75. package/tests/mcp.e2e.ts +0 -214
  76. package/tests/mcp.service.test.ts +0 -53
  77. package/tests/meetSdkRemoteConfig.test.ts +0 -482
  78. package/tests/meetSdkRemoteGradle.test.ts +0 -414
  79. package/tests/pipeline.android.test.ts +0 -149
  80. package/tests/pipeline.integration-json.test.ts +0 -58
  81. package/tests/pipeline.ios.test.ts +0 -609
  82. package/tests/pipeline.preview.patch.test.ts +0 -85
  83. package/tests/platformSelection.test.ts +0 -77
  84. package/tests/sdkHomeDownload.test.ts +0 -275
  85. package/tests/sdkVersionConfig.test.ts +0 -131
  86. package/tests/topsdk.test.ts +0 -53
  87. package/tests/topsdkDownloadSdkConfig.test.ts +0 -81
  88. package/tests/topsdkFeatureModules.test.ts +0 -116
@@ -1,33 +0,0 @@
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
- });
@@ -1,29 +0,0 @@
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
- });
@@ -1,23 +0,0 @@
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
- });
@@ -1,21 +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 { resolveIosSdkRoot } from "../src/ios/sdkBundle.js";
6
- import { MEET_SDK_TOOL_CACHE_ROOT } from "../src/cache.js";
7
-
8
- const pkgRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
9
-
10
- describe("resolveIosSdkRoot", () => {
11
- it("uses only the iOS SDK cache", () => {
12
- try {
13
- const root = resolveIosSdkRoot(pkgRoot);
14
- expect(root).toContain(`${path.sep}.cache${path.sep}meet-sdk-tool${path.sep}sdk${path.sep}ios`);
15
- expect(fs.existsSync(path.join(root, "sdk", "topsdkConfig.t.json"))).toBe(true);
16
- expect(fs.existsSync(path.join(root, "plugins"))).toBe(true);
17
- } catch (e) {
18
- expect(e instanceof Error ? e.message : String(e)).toContain(path.join(MEET_SDK_TOOL_CACHE_ROOT, "sdk", "ios"));
19
- }
20
- });
21
- });
@@ -1,15 +0,0 @@
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
- });
@@ -1,30 +0,0 @@
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
- });
package/tests/mcp.e2e.ts DELETED
@@ -1,214 +0,0 @@
1
- import fs from "node:fs";
2
- import os from "node:os";
3
- import path from "node:path";
4
- import { fileURLToPath, pathToFileURL } from "node:url";
5
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
6
- import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
7
- import { afterEach, beforeEach, describe, expect, it } from "vitest";
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", "android-latest-project");
12
- const remoteConfigFixture = path.join(pkgRoot, "fixtures", "meetsdk-remote-config.mock.json");
13
- const mcpEntry = path.join(pkgRoot, "dist", "mcp-entry.js");
14
-
15
- function copyAndroidProjectToTemp(): string {
16
- const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "meet-mcp-e2e-"));
17
- const projectRoot = path.join(tmpRoot, "android-project");
18
- fs.cpSync(androidFixtureRoot, projectRoot, { recursive: true });
19
- return projectRoot;
20
- }
21
-
22
- function createMockFetchPreload(): { path: string; cleanup: () => void } {
23
- const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "meet-mcp-fetch-"));
24
- const preloadPath = path.join(tmpRoot, "mock-fetch.mjs");
25
- const remoteConfigText = fs.readFileSync(remoteConfigFixture, "utf8");
26
- const preload = `
27
- const remoteConfigText = ${JSON.stringify(remoteConfigText)};
28
- const sdkHomeVersionResponse = {
29
- code: 200,
30
- data: {
31
- result: {
32
- android: { ver: "1.6.1.3", date: "2026-05-25" },
33
- ios: { ver: "1.6.0.5", date: "2026-06-09" }
34
- }
35
- }
36
- };
37
-
38
- function jsonResponse(body) {
39
- return new Response(JSON.stringify(body, null, 2), {
40
- status: 200,
41
- headers: { "content-type": "application/json; charset=utf-8" }
42
- });
43
- }
44
-
45
- globalThis.fetch = async (input) => {
46
- const url = new URL(typeof input === "string" ? input : input.url);
47
- if (url.pathname === "/sdk/home/version") {
48
- return jsonResponse(sdkHomeVersionResponse);
49
- }
50
- if (url.pathname === "/console/openSDK/downloadSDKConfig") {
51
- return new Response(remoteConfigText, {
52
- status: 200,
53
- headers: { "content-type": "application/json; charset=utf-8" }
54
- });
55
- }
56
- if (url.pathname === "/firebase/google-services.json" || url.pathname.endsWith(".json")) {
57
- return jsonResponse({ project_info: { project_id: "mock-project" }, client: [] });
58
- }
59
- return new Response("Unhandled mock route: " + url.pathname, { status: 404 });
60
- };
61
- `;
62
- fs.writeFileSync(preloadPath, preload);
63
- return {
64
- path: preloadPath,
65
- cleanup: () => fs.rmSync(tmpRoot, { recursive: true, force: true }),
66
- };
67
- }
68
-
69
- function childEnv(baseUrl: string, preloadPath: string): Record<string, string> {
70
- const env = Object.fromEntries(
71
- Object.entries(process.env).filter((entry): entry is [string, string] => typeof entry[1] === "string")
72
- );
73
- const preloadOption = `--import=${pathToFileURL(preloadPath).href}`;
74
- return {
75
- ...env,
76
- NODE_OPTIONS: [env.NODE_OPTIONS, preloadOption].filter(Boolean).join(" "),
77
- TOPSDK_API_BASE_URL: baseUrl,
78
- MEETGAMES_SDK_HOME_API_BASE_URL: baseUrl,
79
- };
80
- }
81
-
82
- async function connectMcpClient(baseUrl: string, preloadPath: string): Promise<Client> {
83
- const client = new Client({ name: "meet-sdk-tool-mcp-e2e", version: "1.0.0" });
84
- const transport = new StdioClientTransport({
85
- command: process.execPath,
86
- args: [mcpEntry],
87
- cwd: pkgRoot,
88
- env: childEnv(baseUrl, preloadPath),
89
- stderr: "pipe",
90
- });
91
- await client.connect(transport);
92
- return client;
93
- }
94
-
95
- function structured(result: Awaited<ReturnType<Client["callTool"]>>): Record<string, unknown> {
96
- expect("structuredContent" in result).toBe(true);
97
- const data = "structuredContent" in result ? result.structuredContent : undefined;
98
- expect(data).toBeTruthy();
99
- return data as Record<string, unknown>;
100
- }
101
-
102
- describe("meetgames MCP stdio server", () => {
103
- const mockBaseUrl = "https://meet-sdk-tool-mcp-e2e.invalid";
104
- let mockFetchPreload: ReturnType<typeof createMockFetchPreload>;
105
- let client: Client;
106
- const tmpRoots: string[] = [];
107
-
108
- beforeEach(async () => {
109
- expect(fs.existsSync(mcpEntry)).toBe(true);
110
- mockFetchPreload = createMockFetchPreload();
111
- client = await connectMcpClient(mockBaseUrl, mockFetchPreload.path);
112
- });
113
-
114
- afterEach(async () => {
115
- await client?.close().catch(() => undefined);
116
- mockFetchPreload?.cleanup();
117
- for (const root of tmpRoots.splice(0)) {
118
- fs.rmSync(root, { recursive: true, force: true });
119
- }
120
- });
121
-
122
- it("lists all public meetgames tools", async () => {
123
- const { tools } = await client.listTools();
124
- expect(tools.map((tool) => tool.name).sort()).toEqual([
125
- "meetgames_doctor",
126
- "meetgames_fetch_config",
127
- "meetgames_integrate_apply",
128
- "meetgames_integrate_dry_run",
129
- "meetgames_setup",
130
- ]);
131
- });
132
-
133
- it("runs doctor and integrate dry-run through stdio", async () => {
134
- const projectRoot = copyAndroidProjectToTemp();
135
- tmpRoots.push(path.dirname(projectRoot));
136
-
137
- const doctor = structured(
138
- await client.callTool({
139
- name: "meetgames_doctor",
140
- arguments: { projectRoot, appTarget: "app" },
141
- })
142
- );
143
- expect(doctor.projectRoot).toBe(projectRoot);
144
- expect(doctor.platform).toBe("android");
145
- expect((doctor.android as { moduleName?: string }).moduleName).toBe(":app");
146
-
147
- const dryRun = structured(
148
- await client.callTool({
149
- name: "meetgames_integrate_dry_run",
150
- arguments: { projectRoot, appTarget: "app" },
151
- })
152
- );
153
- expect(dryRun.dryRun).toBe(true);
154
- expect(dryRun.hasErrors).toBe(false);
155
- expect(String(dryRun.patch)).toContain("TOPSDK AUTO");
156
- });
157
-
158
- it("runs fetch-config and setup dry-run through stdio", async () => {
159
- const projectRoot = copyAndroidProjectToTemp();
160
- tmpRoots.push(path.dirname(projectRoot));
161
- fs.rmSync(path.join(projectRoot, "meetsdk-remote-config.json"), { force: true });
162
-
163
- const fetched = structured(
164
- await client.callTool({
165
- name: "meetgames_fetch_config",
166
- arguments: {
167
- projectRoot,
168
- env: "test",
169
- appId: "mock-topsdk-app-id",
170
- appSecret: "mock-secret",
171
- channelType: "GOOGLE",
172
- },
173
- })
174
- );
175
- expect(fetched.env).toBe("test");
176
- expect(String(fetched.requestUrl)).toContain("/console/openSDK/downloadSDKConfig");
177
- expect(fs.existsSync(path.join(projectRoot, "meetsdk-remote-config.json"))).toBe(false);
178
- expect(fs.readFileSync(String(fetched.outputPath), "utf8")).toBe(fs.readFileSync(remoteConfigFixture, "utf8"));
179
-
180
- const setup = structured(
181
- await client.callTool({
182
- name: "meetgames_setup",
183
- arguments: {
184
- projectRoot,
185
- env: "test",
186
- appId: "mock-topsdk-app-id",
187
- appSecret: "mock-secret",
188
- channelType: "GOOGLE",
189
- appTarget: "app",
190
- dryRun: true,
191
- },
192
- })
193
- );
194
- expect((setup.fetch as { env?: string }).env).toBe("test");
195
- expect((setup.integrate as { dryRun?: boolean; hasErrors?: boolean }).dryRun).toBe(true);
196
- expect((setup.integrate as { dryRun?: boolean; hasErrors?: boolean }).hasErrors).toBe(false);
197
- });
198
-
199
- it("runs integrate apply through stdio against a temporary fixture", async () => {
200
- const projectRoot = copyAndroidProjectToTemp();
201
- tmpRoots.push(path.dirname(projectRoot));
202
-
203
- const applied = structured(
204
- await client.callTool({
205
- name: "meetgames_integrate_apply",
206
- arguments: { projectRoot, appTarget: "app" },
207
- })
208
- );
209
- expect(applied.dryRun).toBe(false);
210
- expect((applied.report as { errors?: string[] }).errors).toEqual([]);
211
- expect(applied.hasErrors).toBe(false);
212
- expect(fs.readFileSync(path.join(projectRoot, "app", "build.gradle"), "utf8")).toContain("TOPSDK AUTO");
213
- });
214
- });
@@ -1,53 +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 { meetgamesDoctor, meetgamesIntegrate } from "../src/mcp/service.js";
5
-
6
- const here = path.dirname(fileURLToPath(import.meta.url));
7
- const pkgRoot = path.resolve(here, "..");
8
- const androidLatestRoot = path.join(pkgRoot, "fixtures", "android-test-project", "android-latest-project");
9
-
10
- function stubSdkHomeVersion(): void {
11
- vi.stubGlobal(
12
- "fetch",
13
- vi.fn(async () => ({
14
- ok: true,
15
- status: 200,
16
- text: async () =>
17
- JSON.stringify({
18
- code: 200,
19
- data: {
20
- result: {
21
- android: { ver: "1.6.1.3", date: "2026-05-25" },
22
- ios: { ver: "1.6.0.5", date: "2026-06-09" },
23
- },
24
- },
25
- }),
26
- })) as unknown as typeof fetch
27
- );
28
- }
29
-
30
- describe("mcp service", () => {
31
- beforeEach(() => {
32
- stubSdkHomeVersion();
33
- });
34
-
35
- afterEach(() => {
36
- vi.unstubAllGlobals();
37
- });
38
-
39
- it("doctor returns android detection summary", () => {
40
- const summary = meetgamesDoctor({ projectRoot: androidLatestRoot, appTarget: "app" });
41
- expect(summary.projectRoot).toBe(androidLatestRoot);
42
- expect((summary.android as { ok: boolean }).ok).toBe(true);
43
- expect((summary.android as { moduleName: string }).moduleName).toBe(":app");
44
- });
45
-
46
- it("integrate dry-run returns patch and no errors", async () => {
47
- const result = await meetgamesIntegrate({ projectRoot: androidLatestRoot, dryRun: true });
48
- expect(result.dryRun).toBe(true);
49
- expect(result.patch.length).toBeGreaterThan(0);
50
- const report = result.report as { errors: string[] };
51
- expect(report.errors).toEqual([]);
52
- });
53
- });