@leonxin/meetgames 0.1.16 → 0.1.17
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.
- package/config/meetsdk-ios.json +2 -2
- package/dist/cache.d.ts +1 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +1 -1
- package/dist/cache.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +16 -17
- package/dist/cli.js.map +1 -1
- package/dist/ios/integrate.d.ts.map +1 -1
- package/dist/ios/integrate.js +0 -1
- package/dist/ios/integrate.js.map +1 -1
- package/dist/ios/pbxprojEditor.d.ts.map +1 -1
- package/dist/ios/pbxprojEditor.js +5 -8
- package/dist/ios/pbxprojEditor.js.map +1 -1
- package/dist/remote/sdkHomeDownload.d.ts +4 -3
- package/dist/remote/sdkHomeDownload.d.ts.map +1 -1
- package/dist/remote/sdkHomeDownload.js +103 -26
- package/dist/remote/sdkHomeDownload.js.map +1 -1
- package/package.json +1 -1
- package/src/cache.ts +2 -1
- package/src/cli.ts +13 -17
- package/src/ios/integrate.ts +0 -1
- package/src/ios/pbxprojEditor.ts +6 -8
- package/src/remote/sdkHomeDownload.ts +109 -29
- package/tests/sdkHomeDownload.test.ts +100 -0
|
@@ -2,16 +2,19 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
5
6
|
import {
|
|
6
7
|
DEFAULT_IOS_SDK_PLUGINS,
|
|
7
8
|
buildSdkHomeDownloadUrl,
|
|
8
9
|
buildSdkHomeVersionUrl,
|
|
10
|
+
downloadIosSdkToBundled,
|
|
9
11
|
fetchSdkHomeIosDownloadUrl,
|
|
10
12
|
fetchSdkHomeIosVersion,
|
|
11
13
|
fetchSdkHomeVersions,
|
|
12
14
|
resolveIosSdkRootFromDirectory,
|
|
13
15
|
resolveIosSdkZipFileName,
|
|
14
16
|
} from "../src/remote/sdkHomeDownload.js";
|
|
17
|
+
import { resolveIosSdkCacheLayout } from "../src/cache.js";
|
|
15
18
|
|
|
16
19
|
describe("sdk-home iOS SDK download client", () => {
|
|
17
20
|
afterEach(() => {
|
|
@@ -121,4 +124,101 @@ describe("sdk-home iOS SDK download client", () => {
|
|
|
121
124
|
fs.rmSync(root, { recursive: true, force: true });
|
|
122
125
|
}
|
|
123
126
|
});
|
|
127
|
+
|
|
128
|
+
it("reuses an existing iOS SDK cache for the latest server version", async () => {
|
|
129
|
+
const version = "99.88.77-cache-test";
|
|
130
|
+
const cacheRoot = fs.mkdtempSync(path.join(os.tmpdir(), "meet-sdk-tool-cache-"));
|
|
131
|
+
const cacheLayout = resolveIosSdkCacheLayout({
|
|
132
|
+
version,
|
|
133
|
+
packageType: "native",
|
|
134
|
+
plugins: [...DEFAULT_IOS_SDK_PLUGINS],
|
|
135
|
+
cacheRoot,
|
|
136
|
+
});
|
|
137
|
+
fs.mkdirSync(path.join(cacheLayout.extractDir, "sdk"), { recursive: true });
|
|
138
|
+
fs.mkdirSync(path.join(cacheLayout.extractDir, "plugins"), { recursive: true });
|
|
139
|
+
const fetchMock = vi.fn(async (input: string | URL) => {
|
|
140
|
+
const url = String(input);
|
|
141
|
+
if (url.includes("/sdk/home/sdk-download/getDownLoadUrl")) {
|
|
142
|
+
throw new Error("download URL should not be requested when cache is current");
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
ok: true,
|
|
146
|
+
status: 200,
|
|
147
|
+
text: async () =>
|
|
148
|
+
JSON.stringify({
|
|
149
|
+
code: 200,
|
|
150
|
+
data: {
|
|
151
|
+
result: {
|
|
152
|
+
android: { ver: "1.0.0", date: "2026-01-01" },
|
|
153
|
+
ios: { ver: version, date: "2026-06-26" },
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
}),
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
const result = await downloadIosSdkToBundled(path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."), {
|
|
163
|
+
baseUrl: "https://example.com",
|
|
164
|
+
cacheRoot,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
expect(result.version).toBe(version);
|
|
168
|
+
expect(result.downloaded).toBe(false);
|
|
169
|
+
expect(result.resolvedSdkRoot).toBe(cacheLayout.extractDir);
|
|
170
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
171
|
+
} finally {
|
|
172
|
+
fs.rmSync(cacheRoot, { recursive: true, force: true });
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("reuses a higher local iOS SDK cache instead of downloading an older server version", async () => {
|
|
177
|
+
const serverVersion = "99.88.77-cache-test";
|
|
178
|
+
const cachedVersion = "99.88.78-cache-test";
|
|
179
|
+
const cacheRoot = fs.mkdtempSync(path.join(os.tmpdir(), "meet-sdk-tool-cache-"));
|
|
180
|
+
const cacheLayout = resolveIosSdkCacheLayout({
|
|
181
|
+
version: cachedVersion,
|
|
182
|
+
packageType: "native",
|
|
183
|
+
plugins: [...DEFAULT_IOS_SDK_PLUGINS],
|
|
184
|
+
cacheRoot,
|
|
185
|
+
});
|
|
186
|
+
fs.mkdirSync(path.join(cacheLayout.extractDir, "sdk"), { recursive: true });
|
|
187
|
+
fs.mkdirSync(path.join(cacheLayout.extractDir, "plugins"), { recursive: true });
|
|
188
|
+
const fetchMock = vi.fn(async (input: string | URL) => {
|
|
189
|
+
const url = String(input);
|
|
190
|
+
if (url.includes("/sdk/home/sdk-download/getDownLoadUrl")) {
|
|
191
|
+
throw new Error("download URL should not be requested when a higher cache is available");
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
ok: true,
|
|
195
|
+
status: 200,
|
|
196
|
+
text: async () =>
|
|
197
|
+
JSON.stringify({
|
|
198
|
+
code: 200,
|
|
199
|
+
data: {
|
|
200
|
+
result: {
|
|
201
|
+
android: { ver: "1.0.0", date: "2026-01-01" },
|
|
202
|
+
ios: { ver: serverVersion, date: "2026-06-26" },
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
}),
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
vi.stubGlobal("fetch", fetchMock as unknown as typeof fetch);
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
const result = await downloadIosSdkToBundled(path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."), {
|
|
212
|
+
baseUrl: "https://example.com",
|
|
213
|
+
cacheRoot,
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
expect(result.version).toBe(cachedVersion);
|
|
217
|
+
expect(result.downloaded).toBe(false);
|
|
218
|
+
expect(result.resolvedSdkRoot).toBe(cacheLayout.extractDir);
|
|
219
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
220
|
+
} finally {
|
|
221
|
+
fs.rmSync(cacheRoot, { recursive: true, force: true });
|
|
222
|
+
}
|
|
223
|
+
});
|
|
124
224
|
});
|