GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — t3code/scripts/merge-update-manifests.test.ts at main · SivanTechDev/t3code Expand file tree/ Copy pathmerge-update-manifests.test.tsMore file actions 308 lines (273 loc) · 8.5 KB / Copy pathmerge-update-manifests.test.tsFile metadata and controls308 lines (273 loc) · 8.5 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 import * as NodeServices from "@effect/platform-node/NodeServices"; import { assert, describe, it } from "@effect/vitest"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; import * as Path from "effect/Path"; import { Command, CliError } from "effect/unstable/cli"; import { mergePlatformUpdateManifests, mergeUpdateManifestsCommand, parsePlatformUpdateManifest, serializePlatformUpdateManifest, } from "./merge-update-manifests.ts"; const runCli = Command.runWith(mergeUpdateManifestsCommand, { version: "0.0.0" }); describe("merge-update-manifests", () => { it("merges arm64 and x64 macOS update manifests into one multi-arch manifest", () => { const arm64 = parsePlatformUpdateManifest( "mac", `version: 0.0.4 files: - url: T3-Code-0.0.4-arm64.zip sha512: arm64zip size: 125621344 - url: T3-Code-0.0.4-arm64.dmg sha512: arm64dmg size: 131754935 path: T3-Code-0.0.4-arm64.zip sha512: arm64zip releaseDate: '2026-03-07T10:32:14.587Z' `, "latest-mac.yml", ); const x64 = parsePlatformUpdateManifest( "mac", `version: 0.0.4 files: - url: T3-Code-0.0.4-x64.zip sha512: x64zip size: 132000112 - url: T3-Code-0.0.4-x64.dmg sha512: x64dmg size: 138148807 path: T3-Code-0.0.4-x64.zip sha512: x64zip releaseDate: '2026-03-07T10:36:07.540Z' `, "latest-mac-x64.yml", ); const merged = mergePlatformUpdateManifests("mac", arm64, x64); assert.equal(merged.version, "0.0.4"); assert.equal(merged.releaseDate, "2026-03-07T10:36:07.540Z"); assert.deepStrictEqual( merged.files.map((file) => file.url), [ "T3-Code-0.0.4-arm64.zip", "T3-Code-0.0.4-arm64.dmg", "T3-Code-0.0.4-x64.zip", "T3-Code-0.0.4-x64.dmg", ], ); const serialized = serializePlatformUpdateManifest("mac", merged); assert.ok(!serialized.includes("path:")); assert.equal((serialized.match(/- url:/g) ?? []).length, 4); }); it("merges arm64 and x64 Windows update manifests into one multi-arch manifest", () => { const arm64 = parsePlatformUpdateManifest( "win", `version: 0.0.4 files: - url: T3-Code-0.0.4-arm64.exe sha512: arm64exe size: 125621344 - url: T3-Code-0.0.4-arm64.exe.blockmap sha512: arm64blockmap size: 131754 path: T3-Code-0.0.4-arm64.exe sha512: arm64exe releaseDate: '2026-03-07T10:32:14.587Z' `, "latest-win-arm64.yml", ); const x64 = parsePlatformUpdateManifest( "win", `version: 0.0.4 files: - url: T3-Code-0.0.4-x64.exe sha512: x64exe size: 132000112 - url: T3-Code-0.0.4-x64.exe.blockmap sha512: x64blockmap size: 138148 path: T3-Code-0.0.4-x64.exe sha512: x64exe releaseDate: '2026-03-07T10:36:07.540Z' `, "latest-win-x64.yml", ); const merged = mergePlatformUpdateManifests("win", arm64, x64); assert.equal(merged.version, "0.0.4"); assert.equal(merged.releaseDate, "2026-03-07T10:36:07.540Z"); assert.deepStrictEqual( merged.files.map((file) => file.url), [ "T3-Code-0.0.4-arm64.exe", "T3-Code-0.0.4-arm64.exe.blockmap", "T3-Code-0.0.4-x64.exe", "T3-Code-0.0.4-x64.exe.blockmap", ], ); const serialized = serializePlatformUpdateManifest("win", merged); assert.ok(!serialized.includes("path:")); assert.equal((serialized.match(/- url:/g) ?? []).length, 4); }); it("rejects mismatched manifest versions", () => { const primary = parsePlatformUpdateManifest( "win", `version: 0.0.4 files: - url: T3-Code-0.0.4-arm64.exe sha512: arm64exe size: 1 releaseDate: '2026-03-07T10:32:14.587Z' `, "latest-win-arm64.yml", ); const secondary = parsePlatformUpdateManifest( "win", `version: 0.0.5 files: - url: T3-Code-0.0.5-x64.exe sha512: x64exe size: 1 releaseDate: '2026-03-07T10:36:07.540Z' `, "latest-win-x64.yml", ); assert.throws( () => mergePlatformUpdateManifests("win", primary, secondary), /different versions/, ); }); it("preserves quoted scalars as strings", () => { const manifest = parsePlatformUpdateManifest( "mac", `version: '1.0' files: - url: T3-Code-1.0-x64.zip sha512: zipsha size: 1 releaseName: 'true' minimumSystemVersion: '13.0' stagingPercentage: 50 releaseDate: '2026-03-07T10:36:07.540Z' `, "latest-mac.yml", ); assert.equal(manifest.version, "1.0"); assert.equal(manifest.extras.releaseName, "true"); assert.equal(manifest.extras.minimumSystemVersion, "13.0"); assert.equal(manifest.extras.stagingPercentage, 50); }); it("round-trips numeric-looking versions as strings", () => { const original = parsePlatformUpdateManifest( "win", `version: '1.0' files: - url: T3-Code-1.0-x64.exe sha512: exesha size: 1 releaseDate: '2026-03-07T10:36:07.540Z' `, "latest-win-x64.yml", ); const serialized = serializePlatformUpdateManifest("win", original); assert.ok(serialized.includes("version: '1.0'")); const reparsed = parsePlatformUpdateManifest("win", serialized, "latest-win-x64.yml"); assert.equal(reparsed.version, "1.0"); }); }); it.layer(NodeServices.layer)("merge-update-manifests cli", (it) => { const arm64MacManifest = `version: 0.0.4 files: - url: T3-Code-0.0.4-arm64.zip sha512: arm64zip size: 125621344 - url: T3-Code-0.0.4-arm64.dmg sha512: arm64dmg size: 131754935 path: T3-Code-0.0.4-arm64.zip sha512: arm64zip releaseDate: '2026-03-07T10:32:14.587Z' `; const x64MacManifest = `version: 0.0.4 files: - url: T3-Code-0.0.4-x64.zip sha512: x64zip size: 132000112 - url: T3-Code-0.0.4-x64.dmg sha512: x64dmg size: 138148807 path: T3-Code-0.0.4-x64.zip sha512: x64zip releaseDate: '2026-03-07T10:36:07.540Z' `; it.effect("writes the merged manifest back to the primary path by default", () => Effect.gen(function* () { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "merge-update-manifests-cli-", }); const primaryPath = path.join(baseDir, "latest-mac.yml"); const secondaryPath = path.join(baseDir, "latest-mac-x64.yml"); yield* fs.writeFileString(primaryPath, arm64MacManifest); yield* fs.writeFileString(secondaryPath, x64MacManifest); yield* runCli(["--platform", "mac", primaryPath, secondaryPath]); const merged = yield* fs.readFileString(primaryPath); assert.ok(merged.includes("T3-Code-0.0.4-arm64.zip")); assert.ok(merged.includes("T3-Code-0.0.4-x64.zip")); assert.ok(!merged.includes("path:")); }), ); it.effect("writes the merged manifest to an explicit output path", () => Effect.gen(function* () { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "merge-update-manifests-cli-output-", }); const primaryPath = path.join(baseDir, "latest-win-arm64.yml"); const secondaryPath = path.join(baseDir, "latest-win-x64.yml"); const outputPath = path.join(baseDir, "latest-win.yml"); yield* fs.writeFileString( primaryPath, `version: 0.0.4 files: - url: T3-Code-0.0.4-arm64.exe sha512: arm64exe size: 125621344 releaseDate: '2026-03-07T10:32:14.587Z' `, ); yield* fs.writeFileString( secondaryPath, `version: 0.0.4 files: - url: T3-Code-0.0.4-x64.exe sha512: x64exe size: 132000112 releaseDate: '2026-03-07T10:36:07.540Z' `, ); yield* runCli(["--platform", "win", primaryPath, secondaryPath, outputPath]); const merged = yield* fs.readFileString(outputPath); assert.ok(merged.includes("T3-Code-0.0.4-arm64.exe")); assert.ok(merged.includes("T3-Code-0.0.4-x64.exe")); }), ); it.effect("rejects invalid platform values during cli parsing", () => Effect.gen(function* () { const error = yield* runCli(["--platform", "linux", "a.yml", "b.yml"]).pipe(Effect.flip); if (!CliError.isCliError(error)) { assert.fail(`Expected CliError, got ${String(error)}`); } const platformError = error._tag === "ShowHelp" ? (error.errors[0] as CliError.CliError | undefined) : error; if (!platformError || platformError._tag !== "InvalidValue") { assert.fail(`Expected InvalidValue, got ${String(platformError?._tag)}`); } assert.equal(platformError.option, "platform"); assert.equal(platformError.value, "linux"); }), ); }); |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |