diff --git a/CHANGELOG.md b/CHANGELOG.md index 598c0f449..4e3701dd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ # Change Log +## 2025-05-06 - CLI 0.17.4 + +- fix: fully install go sdk in dev mode [#811](https://github.com/hypermodeinc/modus/pull/811) + ## 2025-04-29 - Go SDK 0.17.4 - fix: Relax postgresql connString regex to allow host to be templated [#830](https://github.com/hypermodeinc/modus/pull/830) diff --git a/cli/src/commands/dev/index.ts b/cli/src/commands/dev/index.ts index 55dd56110..41cc14c91 100644 --- a/cli/src/commands/dev/index.ts +++ b/cli/src/commands/dev/index.ts @@ -25,6 +25,7 @@ import { getAppInfo } from "../../util/appinfo.js"; import { isOnline, withSpinner } from "../../util/index.js"; import { readHypermodeSettings } from "../../util/hypermode.js"; import BuildCommand from "../build/index.js"; +import SDKInstallCommand from "../sdk/install/index.js"; import { BaseCommand } from "../../baseCommand.js"; const MANIFEST_FILE = "modus.json"; @@ -85,16 +86,7 @@ export default class DevCommand extends BaseCommand { } if (!(await vi.sdkVersionIsInstalled(sdk, sdkVersion))) { - const sdkText = `Modus ${sdk} SDK ${sdkVersion}`; - await withSpinner(chalk.dim("Downloading and installing " + sdkText), async (spinner) => { - try { - await installer.installSDK(sdk, sdkVersion); - } catch (e) { - spinner.fail(chalk.red(`Failed to download ${sdkText}`)); - throw e; - } - spinner.succeed(chalk.dim(`Installed ${sdkText}`)); - }); + await SDKInstallCommand.run([sdk, sdkVersion, "--no-logo"]); } let runtimeVersion = flags.runtime; diff --git a/cli/src/util/versioninfo.ts b/cli/src/util/versioninfo.ts index de744a6b2..a3f918917 100644 --- a/cli/src/util/versioninfo.ts +++ b/cli/src/util/versioninfo.ts @@ -7,7 +7,9 @@ * SPDX-License-Identifier: Apache-2.0 */ +import chalk from "chalk"; import semver from "semver"; +import os from "node:os"; import path from "node:path"; import * as http from "./http.js"; import * as fs from "./fs.js"; @@ -179,7 +181,28 @@ export async function runtimeReleaseExists(version: string): Promise { } export async function sdkVersionIsInstalled(sdk: globals.SDK, version: string): Promise { - return await fs.exists(getSdkPath(sdk, version)); + // normal check for SDK path + const sdkPath = getSdkPath(sdk, version); + const installed = await fs.exists(sdkPath); + if (!installed) { + return false; + } + + // extra check for Go build tool, due to prior issue with it not being installed in all cases + if (sdk === globals.SDK.Go) { + const ext = os.platform() === "win32" ? ".exe" : ""; + const buildTool = path.join(sdkPath, "modus-go-build" + ext); + if (await fs.exists(buildTool)) { + return true; + } + + // SDK installed, but build tool not found, so delete and return false so it can be reinstalled + console.log(chalk.yellow(`ⓘ Detected incomplete installation of Modus Go SDK ${version}. Reinstalling...`)); + await fs.rm(sdkPath, { recursive: true, force: true }); + return false; + } + + return installed; } export async function runtimeVersionIsInstalled(version: string): Promise {