Skip to content

Commit

Permalink
feat: Add support for ms-vscode.js-debug
Browse files Browse the repository at this point in the history
  • Loading branch information
hverlin committed Nov 14, 2024
1 parent 93ae149 commit ae72c82
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 41 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions src/utils/fileUtils.ts
Original file line number Diff line number Diff line change
@@ -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()}/`);
Expand Down Expand Up @@ -69,7 +68,7 @@ export async function isExecutable(filePath: string): Promise<boolean> {
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;
}
Expand Down
72 changes: 36 additions & 36 deletions src/utils/miseDoctorParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
};

Expand Down Expand Up @@ -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",
},
};

Expand All @@ -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: "",
},
};
Expand All @@ -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",
},
};

Expand Down
10 changes: 10 additions & 0 deletions src/utils/miseDoctorParser.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { expandPath } from "./fileUtils";

type MiseDirs = {
data?: string;
config?: string;
Expand Down Expand Up @@ -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;
}

Expand Down
15 changes: 15 additions & 0 deletions src/utils/supportedExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,19 @@ export const SUPPORTED_EXTENSIONS: Array<ConfigurableExtension> = [
};
},
},
{
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") },
};
},
},
];

0 comments on commit ae72c82

Please sign in to comment.