@tapi-dev/sdk 0.1.25 → 0.1.27

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/dist/cli.d.ts CHANGED
@@ -126,6 +126,7 @@ export declare function chooseStudioPort(preferred?: number, options?: {
126
126
  portAvailable?: StudioPortAvailable;
127
127
  reapBlockedPorts?: StudioPortReaper;
128
128
  }): Promise<number>;
129
+ export declare function downloadAndVerify(url: string, destination: string, expectedSha256: string, label?: string): Promise<void>;
129
130
  export declare function studioInstanceRecordPathForOptions(options: StudioCliOptions): string;
130
131
  export declare function findPortableStudioServerExe(releaseDir: string, manifest: StudioReleaseManifest): string | undefined;
131
132
  export declare function estimateRequiredExtractionBytes(zipBytes: number): number;
package/dist/cli.js CHANGED
@@ -2480,14 +2480,16 @@ async function runDoctor(options) {
2480
2480
  console.log(`Studio cache: ${options.cacheDir}`);
2481
2481
  console.log(`Workspace: ${options.workspaceRoot ?? "not found"}`);
2482
2482
  console.log(`Project: ${options.projectId ?? "not set"}`);
2483
- const exePath = options.exePath ?? getStudioExecutableCandidates().find((candidate) => existsSync(candidate));
2484
- console.log(`Studio executable: ${exePath && existsSync(exePath) ? exePath : "not found"}`);
2485
2483
  try {
2486
2484
  const manifest = await withCliSpinner("Fetching latest Tapi Studio manifest", () => fetchStudioManifest(options.manifestUrl));
2487
2485
  ensureCompatibleManifest(manifest);
2486
+ const exePath = findInstalledStudioExecutable(options, manifest);
2487
+ console.log(`Studio executable: ${exePath ?? "not found"}`);
2488
2488
  console.log(`Latest Studio: ${manifest.version} (${manifest.platform})`);
2489
2489
  }
2490
2490
  catch (error) {
2491
+ const exePath = options.exePath ?? getStudioExecutableCandidates().find((candidate) => existsSync(candidate));
2492
+ console.log(`Studio executable: ${exePath && existsSync(exePath) ? exePath : "not found"}`);
2491
2493
  console.log(`Latest Studio: unavailable (${formatError(error)})`);
2492
2494
  return 1;
2493
2495
  }
@@ -2588,16 +2590,22 @@ async function requestStudioInstallToken(apiBaseUrl, channel, firebaseIdToken, f
2588
2590
  expiresAt: typeof payload?.expiresAt === "string" ? payload.expiresAt : undefined,
2589
2591
  };
2590
2592
  }
2591
- async function downloadAndVerify(url, destination, expectedSha256, label = "Studio installer") {
2593
+ export async function downloadAndVerify(url, destination, expectedSha256, label = "Studio installer") {
2592
2594
  const partialPath = `${destination}.partial`;
2593
- await downloadFile(url, partialPath, label);
2594
- const actualSha256 = await sha256File(partialPath);
2595
- if (actualSha256 !== expectedSha256.toLowerCase()) {
2595
+ await unlinkIfExists(partialPath);
2596
+ try {
2597
+ await downloadFile(url, partialPath, label);
2598
+ const actualSha256 = await sha256File(partialPath);
2599
+ if (actualSha256 !== expectedSha256.toLowerCase()) {
2600
+ throw new Error(`${label} checksum mismatch. Expected ${expectedSha256}, got ${actualSha256}.`);
2601
+ }
2602
+ await rename(partialPath, destination);
2603
+ console.log(`Verified SHA256: ${actualSha256}`);
2604
+ }
2605
+ catch (error) {
2596
2606
  await unlinkIfExists(partialPath);
2597
- throw new Error(`${label} checksum mismatch. Expected ${expectedSha256}, got ${actualSha256}.`);
2607
+ throw error;
2598
2608
  }
2599
- await rename(partialPath, destination);
2600
- console.log(`Verified SHA256: ${actualSha256}`);
2601
2609
  }
2602
2610
  async function downloadFile(url, destination, label = "download") {
2603
2611
  const response = await fetch(url);
@@ -2956,6 +2964,19 @@ function isPortableStudioServerManifest(manifest) {
2956
2964
  const kind = String(manifest.installerKind || "").toLowerCase();
2957
2965
  return kind === "portable-server" || manifest.artifactName.toLowerCase().endsWith(".zip");
2958
2966
  }
2967
+ function findInstalledStudioExecutable(options, manifest) {
2968
+ if (options.exePath) {
2969
+ return existsSync(options.exePath) ? options.exePath : undefined;
2970
+ }
2971
+ const legacyDesktopExe = getStudioExecutableCandidates().find((candidate) => existsSync(candidate));
2972
+ if (legacyDesktopExe) {
2973
+ return legacyDesktopExe;
2974
+ }
2975
+ if (!isPortableStudioServerManifest(manifest)) {
2976
+ return undefined;
2977
+ }
2978
+ return findPortableStudioServerExe(portableStudioServerReleaseDir(manifest, options.installDir), manifest);
2979
+ }
2959
2980
  function portableStudioServerReleaseDir(manifest, releasesDir = getDefaultPortableStudioServerReleasesDir()) {
2960
2981
  return join(releasesDir, safePathSegment(manifest.version));
2961
2982
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapi-dev/sdk",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",