@vlandoss/run-run 0.0.6-git-3835394.0 → 0.0.6-git-290164e.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vlandoss/run-run",
3
- "version": "0.0.6-git-3835394.0",
3
+ "version": "0.0.6-git-290164e.0",
4
4
  "description": "The CLI toolbox to fullstack common scripts in Variable Land",
5
5
  "homepage": "https://github.com/variableland/dx/tree/main/packages/run-run#readme",
6
6
  "bugs": {
@@ -17,7 +17,7 @@
17
17
  "bin": {
18
18
  "rr": "./bin.ts",
19
19
  "run-run": "./bin.ts",
20
- "rr:biome": "./tools/biome"
20
+ "biome": "./tools/biome"
21
21
  },
22
22
  "files": [
23
23
  "bin",
@@ -33,8 +33,8 @@
33
33
  "is-ci": "4.1.0",
34
34
  "rimraf": "6.0.1",
35
35
  "typescript": "5.8.2",
36
- "@vlandoss/clibuddy": "0.0.4-git-3835394.0",
37
- "@vlandoss/loggy": "0.0.3"
36
+ "@vlandoss/loggy": "0.0.3",
37
+ "@vlandoss/clibuddy": "0.0.4-git-290164e.0"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
@@ -156,8 +156,6 @@ Options:
156
156
 
157
157
  Commands:
158
158
  biome
159
- tsc
160
- rimraf
161
159
  help [command] display help for command
162
160
  "
163
161
  `;
@@ -1,4 +1,5 @@
1
1
  import { createCommand } from "commander";
2
+ import { BiomeService } from "~/services/biome";
2
3
  import type { Context } from "~/services/ctx";
3
4
 
4
5
  export function createFormatCommand(ctx: Context) {
@@ -8,7 +9,7 @@ export function createFormatCommand(ctx: Context) {
8
9
  .option("-c, --check", "check if the code is formatted", true)
9
10
  .option("-f, --fix", "format all the code")
10
11
  .action(async function formatAction(options) {
11
- const $ = ctx.shell.$;
12
+ const { $ } = new BiomeService(ctx.shell);
12
13
  const toolCmd = "biome format --no-errors-on-unmatched --colors=force";
13
14
 
14
15
  if (options.fix) {
@@ -1,4 +1,5 @@
1
1
  import { createCommand } from "commander";
2
+ import { BiomeService } from "~/services/biome";
2
3
  import type { Context } from "~/services/ctx";
3
4
 
4
5
  export function createLintCommand(ctx: Context) {
@@ -7,7 +8,7 @@ export function createLintCommand(ctx: Context) {
7
8
  .option("-c, --check", "check if the code is valid", true)
8
9
  .option("-f, --fix", "try to fix all the code")
9
10
  .action(async function lintAction(options) {
10
- const $ = ctx.shell.$;
11
+ const { $ } = new BiomeService(ctx.shell);
11
12
  const toolCmd = "biome check --colors=force --formatter-enabled=false";
12
13
 
13
14
  if (options.fix) {
@@ -1,5 +1,6 @@
1
1
  import { createCommand } from "commander";
2
2
  import isCI from "is-ci";
3
+ import { BiomeService } from "~/services/biome";
3
4
  import type { Context } from "~/services/ctx";
4
5
 
5
6
  export function createTestStaticCommand(ctx: Context) {
@@ -9,7 +10,7 @@ export function createTestStaticCommand(ctx: Context) {
9
10
  .option("-f, --fix", "try to fix issues automatically")
10
11
  .option("--fix-staged", "try to fix staged files only")
11
12
  .action(async function testStaticAction(options) {
12
- const $ = ctx.shell.$;
13
+ const { $ } = new BiomeService(ctx.shell);
13
14
  const toolCmd = (cmd = "check") => `biome ${cmd} --colors=force`;
14
15
 
15
16
  if (options.fix) {
@@ -1,25 +1,23 @@
1
1
  import { createCommand } from "commander";
2
+ import { BiomeService } from "~/services/biome";
2
3
  import type { Context } from "~/services/ctx";
3
4
 
4
- export function createToolsCommand(ctx: Context) {
5
- function createToolCommandAction(toolBin: string) {
6
- return async function toolAction(_: unknown, { args }: { args: string[] }) {
7
- await ctx.shell.$`${toolBin} ${args.join(" ")}`;
8
- };
9
- }
10
-
11
- function createToolCommand(toolBin: string) {
12
- return createCommand(toolBin)
13
- .helpCommand(false)
14
- .helpOption(false)
15
- .allowExcessArguments(true)
16
- .allowUnknownOption(true)
17
- .action(createToolCommandAction(toolBin));
18
- }
5
+ function createToolCommand(toolBin: string) {
6
+ // biome-ignore format: I prefer multi-line
7
+ return createCommand(toolBin)
8
+ .helpCommand(false)
9
+ .helpOption(false)
10
+ .allowExcessArguments(true)
11
+ .allowUnknownOption(true);
12
+ }
19
13
 
14
+ export function createToolsCommand(ctx: Context) {
20
15
  return createCommand("tools")
21
16
  .description("expose the internal tools 🛠️")
22
- .addCommand(createToolCommand("biome"))
23
- .addCommand(createToolCommand("tsc"))
24
- .addCommand(createToolCommand("rimraf"));
17
+ .addCommand(
18
+ createToolCommand("biome").action((_: unknown, { args }: { args: string[] }) => {
19
+ const biomeService = new BiomeService(ctx.shell);
20
+ biomeService.execute(args);
21
+ }),
22
+ );
25
23
  }
@@ -0,0 +1,25 @@
1
+ import type { ShellService } from "@vlandoss/clibuddy";
2
+ import { gracefullBinDir } from "~/utils/gracefullBinDir";
3
+ import type { ToolService } from "./models";
4
+
5
+ export class BiomeService implements ToolService {
6
+ #shellService: ShellService;
7
+
8
+ constructor(shellService: ShellService) {
9
+ this.#shellService = shellService;
10
+ }
11
+
12
+ get $() {
13
+ return this.#shellService.child({
14
+ preferLocal: this.#getBinDir(),
15
+ }).$;
16
+ }
17
+
18
+ async execute(args: string[]): Promise<void> {
19
+ this.$`biome ${args.join(" ")}`;
20
+ }
21
+
22
+ #getBinDir() {
23
+ return gracefullBinDir(() => require.resolve("@biomejs/biome/bin/biome"));
24
+ }
25
+ }
@@ -0,0 +1,6 @@
1
+ import type { Shell } from "@vlandoss/clibuddy";
2
+
3
+ export interface ToolService {
4
+ $: Shell;
5
+ execute(args: string[]): Promise<void>;
6
+ }
@@ -0,0 +1,14 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { logger } from "~/services/logger";
4
+
5
+ export function gracefullBinDir(binPathResolver: () => string) {
6
+ try {
7
+ const binPath = binPathResolver();
8
+ const isDir = fs.statSync(binPath).isDirectory();
9
+ return isDir ? binPath : path.dirname(binPath);
10
+ } catch (error) {
11
+ logger.error("Error getting bin directory:", error);
12
+ process.exit(1);
13
+ }
14
+ }
package/tools/biome CHANGED
File without changes