Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strong-buckets-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vlandoss/run-run": patch
---

Add tsdown to tools
14 changes: 13 additions & 1 deletion packages/run-run/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@
"author": "rcrd <rcrd@variable.land>",
"type": "module",
"exports": {
"./config": "./src/lib/config.ts"
"./config": {
"bun": "./src/lib/config.ts",
"types": "./dist/config.d.mts",
"default": "./dist/config.mjs"
},
"./tools/*": {
"bun": "./src/lib/tools/*.ts",
"types": "./dist/tools/*.d.mts",
"default": "./dist/tools/*.mjs"
}
},
"bin": {
"rr": "./bin.ts",
Expand All @@ -25,12 +34,15 @@
},
"files": [
"bin.ts",
"dist",
"src",
"tools",
"tsconfig.json"
],
"scripts": {
"build": "tsdown",
"test": "bun test",
"prepublishOnly": "pnpm build",
"test:types": "rr tsc"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/run-run/src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UserConfig } from "../types/config";
import type { UserConfig } from "../types/config.ts";

export function defineConfig(config: UserConfig) {
return config;
Expand Down
1 change: 1 addition & 0 deletions packages/run-run/src/lib/tools/tsdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "tsdown";
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ Commands:
biome
oxfmt
oxlint
tsdown
help [command] display help for command
"
`;
6 changes: 5 additions & 1 deletion packages/run-run/src/program/commands/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Context } from "#/services/ctx";
import { OxfmtService } from "#/services/oxfmt";
import { OxlintService } from "#/services/oxlint";
import type { ToolService } from "#/services/tool";
import { TsdownService } from "#/services/tsdown";

type ActionParams = {
args: string[];
Expand All @@ -18,6 +19,8 @@ function getToolService(bin: string, shell: ShellService): ToolService {
return new OxfmtService(shell);
case "oxlint":
return new OxlintService(shell);
case "tsdown":
return new TsdownService(shell);
default:
throw new Error(`Unknown tool: ${bin}`);
}
Expand All @@ -41,5 +44,6 @@ export function createToolsCommand(ctx: Context) {
.description("expose the internal tools 🛠️")
.addCommand(createToolCommand("biome", ctx.shell))
.addCommand(createToolCommand("oxfmt", ctx.shell))
.addCommand(createToolCommand("oxlint", ctx.shell));
.addCommand(createToolCommand("oxlint", ctx.shell))
.addCommand(createToolCommand("tsdown", ctx.shell));
}
2 changes: 1 addition & 1 deletion packages/run-run/src/services/biome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class BiomeService extends ToolService implements Formatter, Linter, Stat
super({ bin: "biome", ui: TOOL_LABELS.BIOME, shellService });
}

getBinDir() {
override getBinDir() {
return require.resolve("@biomejs/biome/bin/biome");
}

Expand Down
2 changes: 1 addition & 1 deletion packages/run-run/src/services/oxfmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class OxfmtService extends ToolService implements Formatter {
super({ bin: "oxfmt", ui: TOOL_LABELS.OXFMT, shellService });
}

getBinDir() {
override getBinDir() {
return require.resolve("oxfmt/bin/oxfmt");
}

Expand Down
2 changes: 1 addition & 1 deletion packages/run-run/src/services/oxlint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class OxlintService extends ToolService implements Linter {
super({ bin: "oxlint", ui: TOOL_LABELS.OXLINT, shellService });
}

getBinDir() {
override getBinDir() {
return require.resolve("oxlint/bin/oxlint");
}

Expand Down
6 changes: 4 additions & 2 deletions packages/run-run/src/services/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ export abstract class ToolService {
this.#shellService = shellService;
}

abstract getBinDir(): string;
getBinDir?(): string;

exec(args: string | string[]) {
const $ = this.#shell();
return this.#run($, args);
}

#shell = memoize((cwd?: string) => {
const { getBinDir } = this;

return this.#shellService.child({
cwd,
preferLocal: gracefullBinDir(() => this.getBinDir()),
...(getBinDir && { preferLocal: gracefullBinDir(() => getBinDir()) }),
}).$;
});

Expand Down
9 changes: 9 additions & 0 deletions packages/run-run/src/services/tsdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { ShellService } from "@vlandoss/clibuddy";
import { TOOL_LABELS } from "#/program/ui";
import { ToolService } from "./tool";

export class TsdownService extends ToolService {
constructor(shellService: ShellService) {
super({ bin: "tsdown", ui: TOOL_LABELS.TSDOWN, shellService });
}
}
2 changes: 2 additions & 0 deletions packages/run-run/tools/tsdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
bunx rr tools tsdown "$@"
7 changes: 7 additions & 0 deletions packages/run-run/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from "tsdown";

export default defineConfig({
entry: ["src/lib/**/*.ts"],
format: "esm",
dts: true,
});
7 changes: 7 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"paths": {
"@vlandoss/run-run/*": ["./packages/run-run/src/lib/*"]
}
}
}
Loading