diff --git a/README.md b/README.md index 62fdadb..4fd7eb2 100644 --- a/README.md +++ b/README.md @@ -39,11 +39,14 @@ Extensions are automatically configured to use `mise shims`. You can disable thi If you want to configure it manually, search for `Mise: Configure extension sdk path...` in the command palette. +- [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) +- [Go](https://marketplace.visualstudio.com/items?itemName=golang.Go) +- [Java](https://marketplace.visualstudio.com/items?itemName=oracle.oracle-java) +- [Shellcheck](https://marketplace.visualstudio.com/items?itemName=timonwong.shellcheck) +- [NodeJS](https://marketplace.visualstudio.com/items?itemName=ms-vscode.js-debug) - [Deno](https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno) -- [Ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) - [Bun](https://marketplace.visualstudio.com/items?itemName=oven.bun-vscode) -- [Go](https://marketplace.visualstudio.com/items?itemName=golang.Go) -- [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) +- [Ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) If you want to add one, you can open a PR that updates [src/utils/supportedExtensions.ts](https://github.com/hverlin/mise-vscode/blob/main/src/utils/supportedExtensions.ts) diff --git a/src/utils/fileUtils.ts b/src/utils/fileUtils.ts index 9387c3c..34d056b 100644 --- a/src/utils/fileUtils.ts +++ b/src/utils/fileUtils.ts @@ -1,7 +1,6 @@ import * as fs from "node:fs/promises"; import * as os from "node:os"; import * as path from "node:path"; -import { logger } from "./logger"; export function expandPath(filePath: string): string { return path.normalize(filePath).replace("~/", `${os.homedir()}/`); @@ -69,7 +68,7 @@ export async function isExecutable(filePath: string): Promise { const stats = await fs.stat(filePath); return !!(stats.mode & 0o111); } catch (error) { - logger.info(`${filePath} is not executable: ${error}`); + console.log(`${filePath} is not executable: ${error}`); } return false; } diff --git a/src/utils/miseDoctorParser.test.ts b/src/utils/miseDoctorParser.test.ts index 603e46b..5b368fb 100644 --- a/src/utils/miseDoctorParser.test.ts +++ b/src/utils/miseDoctorParser.test.ts @@ -6,22 +6,22 @@ describe("mise-parser", () => { test("should parse dirs section correctly", () => { const input = `version: 2024.11.8 dirs: - data: ~/.local/share/mise - config: ~/.config/mise - cache: ~/Library/Caches/mise - state: ~/.local/state/mise - shims: ~/.local/share/mise/shims + data: /dev/home/.local/share/mise + config: /dev/home/.config/mise + cache: /dev/home/Library/Caches/mise + state: /dev/home/.local/state/mise + shims: /dev/home/.local/share/mise/shims shell: /bin/zsh`; const expected: MiseConfig = { dirs: { - data: "~/.local/share/mise", - config: "~/.config/mise", - cache: "~/Library/Caches/mise", - state: "~/.local/state/mise", - shims: "~/.local/share/mise/shims", + data: "/dev/home/.local/share/mise", + config: "/dev/home/.config/mise", + cache: "/dev/home/Library/Caches/mise", + state: "/dev/home/.local/state/mise", + shims: "/dev/home/.local/share/mise/shims", }, }; @@ -55,19 +55,19 @@ shell: test("should handle different indentation levels", () => { const input = `version: 2024.11.8 dirs: - data: ~/.local/share/mise - config: ~/.config/mise - cache: ~/Library/Caches/mise - state: ~/.local/state/mise - shims: ~/.local/share/mise/shims`; + data: /dev/home/.local/share/mise + config: /dev/home/.config/mise + cache: /dev/home/Library/Caches/mise + state: /dev/home/.local/state/mise + shims: /dev/home/.local/share/mise/shims`; const expected: MiseConfig = { dirs: { - data: "~/.local/share/mise", - config: "~/.config/mise", - cache: "~/Library/Caches/mise", - state: "~/.local/state/mise", - shims: "~/.local/share/mise/shims", + data: "/dev/home/.local/share/mise", + config: "/dev/home/.config/mise", + cache: "/dev/home/Library/Caches/mise", + state: "/dev/home/.local/state/mise", + shims: "/dev/home/.local/share/mise/shims", }, }; @@ -77,16 +77,16 @@ dirs: test("should handle malformed lines in dirs section", () => { const input = `dirs: - data: ~/.local/share/mise + data: /dev/home/.local/share/mise invalid line : missing key missing_value: - config: ~/.config/mise`; + config: /dev/home/.config/mise`; const expected: MiseConfig = { dirs: { - data: "~/.local/share/mise", - config: "~/.config/mise", + data: "/dev/home/.local/share/mise", + config: "/dev/home/.config/mise", shims: "", }, }; @@ -105,23 +105,23 @@ build_info: Features: DEFAULT, NATIVE_TLS, OPENSSL dirs: - data: ~/.local/share/mise - config: ~/.config/mise - cache: ~/Library/Caches/mise - state: ~/.local/state/mise - shims: ~/.local/share/mise/shims + data: /dev/home/.local/share/mise + config: /dev/home/.config/mise + cache: /dev/home/Library/Caches/mise + state: /dev/home/.local/state/mise + shims: /dev/home/.local/share/mise/shims config_files: - ~/.config/mise/config.toml - ~/Projects/mise-vscode/mise.toml`; + /dev/home/.config/mise/config.toml + /dev/home/Projects/mise-vscode/mise.toml`; const expected: MiseConfig = { dirs: { - data: "~/.local/share/mise", - config: "~/.config/mise", - cache: "~/Library/Caches/mise", - state: "~/.local/state/mise", - shims: "~/.local/share/mise/shims", + data: "/dev/home/.local/share/mise", + config: "/dev/home/.config/mise", + cache: "/dev/home/Library/Caches/mise", + state: "/dev/home/.local/state/mise", + shims: "/dev/home/.local/share/mise/shims", }, }; diff --git a/src/utils/miseDoctorParser.ts b/src/utils/miseDoctorParser.ts index 93240ea..17383c4 100644 --- a/src/utils/miseDoctorParser.ts +++ b/src/utils/miseDoctorParser.ts @@ -1,3 +1,5 @@ +import { expandPath } from "./fileUtils"; + type MiseDirs = { data?: string; config?: string; @@ -50,6 +52,14 @@ function parseMiseConfig(content: string): MiseConfig { } } + for (const [key, value] of Object.entries(result.dirs)) { + if (!value) { + continue; + } + + result.dirs[key] = expandPath(value); + } + return result; } diff --git a/src/utils/supportedExtensions.ts b/src/utils/supportedExtensions.ts index e5aaebd..9546caa 100644 --- a/src/utils/supportedExtensions.ts +++ b/src/utils/supportedExtensions.ts @@ -124,4 +124,19 @@ export const SUPPORTED_EXTENSIONS: Array = [ }; }, }, + { + toolName: "node", + extensionName: "ms-vscode.js-debug", + generateConfiguration: async ( + tool: MiseTool, + miseConfig: MiseConfig, + { useShims }, + ) => { + return { + "debug.javascript.defaultRuntimeExecutable": useShims + ? { "pwa-node": path.join(miseConfig.dirs.shims, "node") } + : { "pwa-node": path.join(tool.install_path, "bin", "node") }, + }; + }, + }, ];