@vlandoss/run-run 0.0.6-git-0c9069c.0 โ 0.0.6
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 +2 -2
- package/src/program/__tests__/__snapshots__/snapshots.test.ts.snap +32 -48
- package/src/program/commands/{test-static.ts โ check.ts} +5 -4
- package/src/program/commands/format.ts +4 -3
- package/src/program/commands/lint.ts +2 -1
- package/src/program/commands/tools.ts +14 -41
- package/src/program/commands/typecheck.ts +2 -2
- package/src/program/index.ts +4 -6
- package/src/services/biome.ts +25 -0
- package/src/services/models.ts +6 -0
- package/src/utils/gracefullBinDir.ts +14 -0
- package/src/program/commands/info-pkg.ts +0 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vlandoss/run-run",
|
|
3
|
-
"version": "0.0.6
|
|
3
|
+
"version": "0.0.6",
|
|
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": {
|
|
@@ -33,7 +33,7 @@
|
|
|
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
|
|
36
|
+
"@vlandoss/clibuddy": "0.0.4",
|
|
37
37
|
"@vlandoss/loggy": "0.0.3"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
@@ -10,13 +10,12 @@ Options:
|
|
|
10
10
|
-h, --help display help for command
|
|
11
11
|
|
|
12
12
|
Commands:
|
|
13
|
-
|
|
13
|
+
check|test:static [options] check format and lint issues ๐
|
|
14
14
|
lint [options] lint the code ๐งน
|
|
15
|
-
|
|
15
|
+
fmt|format [options] format the code ๐จ
|
|
16
|
+
tsc|typecheck check if TypeScript code is well typed ๐จ
|
|
16
17
|
clean [options] delete dirty folders or files such as
|
|
17
18
|
node_modules, etc ๐๏ธ
|
|
18
|
-
typecheck|tsc check if TypeScript code is well typed ๐จ
|
|
19
|
-
info:pkg [options] display run-run package.json โน๏ธ
|
|
20
19
|
help [command] display help for command
|
|
21
20
|
|
|
22
21
|
Acknowledgment:
|
|
@@ -38,13 +37,12 @@ Options:
|
|
|
38
37
|
-h, --help display help for command
|
|
39
38
|
|
|
40
39
|
Commands:
|
|
41
|
-
|
|
40
|
+
check|test:static [options] check format and lint issues ๐
|
|
42
41
|
lint [options] lint the code ๐งน
|
|
43
|
-
|
|
42
|
+
fmt|format [options] format the code ๐จ
|
|
43
|
+
tsc|typecheck check if TypeScript code is well typed ๐จ
|
|
44
44
|
clean [options] delete dirty folders or files such as
|
|
45
45
|
node_modules, etc ๐๏ธ
|
|
46
|
-
typecheck|tsc check if TypeScript code is well typed ๐จ
|
|
47
|
-
info:pkg [options] display run-run package.json โน๏ธ
|
|
48
46
|
help [command] display help for command
|
|
49
47
|
|
|
50
48
|
Acknowledgment:
|
|
@@ -66,17 +64,17 @@ exports[`should match command: "-v" 1`] = `
|
|
|
66
64
|
"
|
|
67
65
|
`;
|
|
68
66
|
|
|
69
|
-
exports[`should match help message for command "
|
|
70
|
-
"Usage: rr
|
|
67
|
+
exports[`should match help message for command "check" 1`] = `
|
|
68
|
+
"Usage: rr check|test:static [options]
|
|
71
69
|
|
|
72
|
-
format
|
|
70
|
+
check format and lint issues ๐
|
|
73
71
|
|
|
74
72
|
Options:
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-h, --help
|
|
73
|
+
-f, --fix try to fix issues automatically
|
|
74
|
+
--fix-staged try to fix staged files only
|
|
75
|
+
-h, --help display help for command
|
|
78
76
|
|
|
79
|
-
Under the hood, this command uses the biome CLI to
|
|
77
|
+
Under the hood, this command uses the biome CLI to check the code.
|
|
80
78
|
"
|
|
81
79
|
`;
|
|
82
80
|
|
|
@@ -94,36 +92,22 @@ Under the hood, this command uses the biome CLI to lint the code.
|
|
|
94
92
|
"
|
|
95
93
|
`;
|
|
96
94
|
|
|
97
|
-
exports[`should match help message for command "
|
|
98
|
-
"Usage: rr
|
|
99
|
-
|
|
100
|
-
check format and lint issues โ
|
|
101
|
-
|
|
102
|
-
Options:
|
|
103
|
-
-f, --fix try to fix issues automatically
|
|
104
|
-
--fix-staged try to fix staged files only
|
|
105
|
-
-h, --help display help for command
|
|
106
|
-
|
|
107
|
-
Under the hood, this command uses the biome CLI to check the code.
|
|
108
|
-
"
|
|
109
|
-
`;
|
|
110
|
-
|
|
111
|
-
exports[`should match help message for command "clean" 1`] = `
|
|
112
|
-
"Usage: rr clean [options]
|
|
95
|
+
exports[`should match help message for command "fmt" 1`] = `
|
|
96
|
+
"Usage: rr fmt|format [options]
|
|
113
97
|
|
|
114
|
-
|
|
98
|
+
format the code ๐จ
|
|
115
99
|
|
|
116
100
|
Options:
|
|
117
|
-
--
|
|
118
|
-
--
|
|
101
|
+
-c, --check check if the code is formatted (default: true)
|
|
102
|
+
-f, --fix format all the code
|
|
119
103
|
-h, --help display help for command
|
|
120
104
|
|
|
121
|
-
Under the hood, this command uses the
|
|
105
|
+
Under the hood, this command uses the biome CLI to format the code.
|
|
122
106
|
"
|
|
123
107
|
`;
|
|
124
108
|
|
|
125
|
-
exports[`should match help message for command "
|
|
126
|
-
"Usage: rr typecheck
|
|
109
|
+
exports[`should match help message for command "tsc" 1`] = `
|
|
110
|
+
"Usage: rr tsc|typecheck [options]
|
|
127
111
|
|
|
128
112
|
check if TypeScript code is well typed ๐จ
|
|
129
113
|
|
|
@@ -134,15 +118,17 @@ Under the hood, this command uses the TypeScript CLI to check the code.
|
|
|
134
118
|
"
|
|
135
119
|
`;
|
|
136
120
|
|
|
137
|
-
exports[`should match help message for command "
|
|
138
|
-
"Usage: rr
|
|
121
|
+
exports[`should match help message for command "clean" 1`] = `
|
|
122
|
+
"Usage: rr clean [options]
|
|
139
123
|
|
|
140
|
-
|
|
124
|
+
delete dirty folders or files such as node_modules, etc ๐๏ธ
|
|
141
125
|
|
|
142
126
|
Options:
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-h, --help
|
|
127
|
+
--only-dist delete 'dist' folders only
|
|
128
|
+
--dry-run outputs the paths that would be deleted
|
|
129
|
+
-h, --help display help for command
|
|
130
|
+
|
|
131
|
+
Under the hood, this command uses the rimraf.js to delete dirty folders or files.
|
|
146
132
|
"
|
|
147
133
|
`;
|
|
148
134
|
|
|
@@ -156,16 +142,14 @@ Options:
|
|
|
156
142
|
|
|
157
143
|
Commands:
|
|
158
144
|
biome
|
|
159
|
-
tsc
|
|
160
|
-
rimraf
|
|
161
145
|
help [command] display help for command
|
|
162
146
|
"
|
|
163
147
|
`;
|
|
164
148
|
|
|
165
|
-
exports[`should match "
|
|
149
|
+
exports[`should match "check" command 1`] = `"biome check --colors=force"`;
|
|
166
150
|
|
|
167
151
|
exports[`should match "lint" command 1`] = `"biome check --colors=force --formatter-enabled=false"`;
|
|
168
152
|
|
|
169
|
-
exports[`should match "
|
|
153
|
+
exports[`should match "fmt" command 1`] = `"biome format --no-errors-on-unmatched --colors=force"`;
|
|
170
154
|
|
|
171
|
-
exports[`should match "
|
|
155
|
+
exports[`should match "tsc" command 1`] = `"tsc --noEmit"`;
|
|
@@ -1,15 +1,16 @@
|
|
|
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
|
-
export function
|
|
6
|
+
export function createCheckCommand(ctx: Context) {
|
|
6
7
|
return createCommand("check")
|
|
7
8
|
.alias("test:static")
|
|
8
|
-
.description("check format and lint issues
|
|
9
|
+
.description("check format and lint issues ๐")
|
|
9
10
|
.option("-f, --fix", "try to fix issues automatically")
|
|
10
11
|
.option("--fix-staged", "try to fix staged files only")
|
|
11
|
-
.action(async function
|
|
12
|
-
const $ = ctx.shell
|
|
12
|
+
.action(async function checkAction(options) {
|
|
13
|
+
const { $ } = new BiomeService(ctx.shell);
|
|
13
14
|
const toolCmd = (cmd = "check") => `biome ${cmd} --colors=force`;
|
|
14
15
|
|
|
15
16
|
if (options.fix) {
|
|
@@ -1,14 +1,15 @@
|
|
|
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) {
|
|
5
|
-
return createCommand("
|
|
6
|
-
.alias("
|
|
6
|
+
return createCommand("fmt")
|
|
7
|
+
.alias("format")
|
|
7
8
|
.description("format the code ๐จ")
|
|
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,50 +1,23 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import type { Shell } from "@vlandoss/clibuddy";
|
|
4
1
|
import { createCommand } from "commander";
|
|
2
|
+
import { BiomeService } from "~/services/biome";
|
|
5
3
|
import type { Context } from "~/services/ctx";
|
|
6
|
-
import { logger } from "~/services/logger";
|
|
7
4
|
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
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);
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
export function createToolsCommand(ctx: Context) {
|
|
20
|
-
function createToolCommandAction(toolBin: string, binResolver?: () => string) {
|
|
21
|
-
return async function toolAction(_: unknown, { args }: { args: string[] }) {
|
|
22
|
-
let $: Shell;
|
|
23
|
-
|
|
24
|
-
if (!binResolver) {
|
|
25
|
-
$ = ctx.shell.$;
|
|
26
|
-
} else {
|
|
27
|
-
$ = ctx.shell.child({
|
|
28
|
-
preferLocal: [gracefullBinDir(binResolver)],
|
|
29
|
-
}).$;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
await $`${toolBin} ${args.join(" ")}`;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function createToolCommand(toolBin: string, binResolver?: () => string) {
|
|
37
|
-
return createCommand(toolBin)
|
|
38
|
-
.helpCommand(false)
|
|
39
|
-
.helpOption(false)
|
|
40
|
-
.allowExcessArguments(true)
|
|
41
|
-
.allowUnknownOption(true)
|
|
42
|
-
.action(createToolCommandAction(toolBin, binResolver));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
15
|
return createCommand("tools")
|
|
46
16
|
.description("expose the internal tools ๐ ๏ธ")
|
|
47
|
-
.addCommand(
|
|
48
|
-
|
|
49
|
-
|
|
17
|
+
.addCommand(
|
|
18
|
+
createToolCommand("biome").action((_: unknown, { args }: { args: string[] }) => {
|
|
19
|
+
const biomeService = new BiomeService(ctx.shell);
|
|
20
|
+
biomeService.execute(args);
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
50
23
|
}
|
|
@@ -4,8 +4,8 @@ import type { Context } from "~/services/ctx";
|
|
|
4
4
|
import { logger } from "~/services/logger";
|
|
5
5
|
|
|
6
6
|
export function createTypecheckCommand(ctx: Context) {
|
|
7
|
-
return createCommand("
|
|
8
|
-
.alias("
|
|
7
|
+
return createCommand("tsc")
|
|
8
|
+
.alias("typecheck")
|
|
9
9
|
.description("check if TypeScript code is well typed ๐จ")
|
|
10
10
|
.action(async function typecheckAction() {
|
|
11
11
|
const { appPkg, shell } = ctx;
|
package/src/program/index.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { getVersion } from "@vlandoss/clibuddy";
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { createContext } from "~/services/ctx";
|
|
4
|
+
import { createCheckCommand } from "./commands/check";
|
|
4
5
|
import { createCleanCommand } from "./commands/clean";
|
|
5
6
|
import { createFormatCommand } from "./commands/format";
|
|
6
|
-
import { createInfoPkgCommand } from "./commands/info-pkg";
|
|
7
7
|
import { createLintCommand } from "./commands/lint";
|
|
8
|
-
import { createTestStaticCommand } from "./commands/test-static";
|
|
9
8
|
import { createToolsCommand } from "./commands/tools";
|
|
10
9
|
import { createTypecheckCommand } from "./commands/typecheck";
|
|
11
10
|
import { BANNER_TEXT, CREDITS_TEXT } from "./ui";
|
|
@@ -22,12 +21,11 @@ export async function createProgram(options: Options) {
|
|
|
22
21
|
.version(getVersion(ctx.binPkg), "-v, --version")
|
|
23
22
|
.addHelpText("before", BANNER_TEXT)
|
|
24
23
|
.addHelpText("after", CREDITS_TEXT)
|
|
25
|
-
.addCommand(
|
|
24
|
+
.addCommand(createCheckCommand(ctx))
|
|
26
25
|
.addCommand(createLintCommand(ctx))
|
|
27
|
-
.addCommand(
|
|
28
|
-
.addCommand(createCleanCommand())
|
|
26
|
+
.addCommand(createFormatCommand(ctx))
|
|
29
27
|
.addCommand(createTypecheckCommand(ctx))
|
|
30
|
-
.addCommand(
|
|
28
|
+
.addCommand(createCleanCommand())
|
|
31
29
|
.addCommand(createToolsCommand(ctx), {
|
|
32
30
|
hidden: true,
|
|
33
31
|
});
|
|
@@ -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,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
|
+
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { createCommand } from "commander";
|
|
2
|
-
import type { Context } from "~/services/ctx";
|
|
3
|
-
import { logger } from "~/services/logger";
|
|
4
|
-
import { get } from "~/utils/get";
|
|
5
|
-
|
|
6
|
-
export function createInfoPkgCommand(ctx: Context) {
|
|
7
|
-
return createCommand("info:pkg")
|
|
8
|
-
.description("display run-run package.json โน๏ธ")
|
|
9
|
-
.option("-f, --filter <filter>", "lodash get id like to filter info by")
|
|
10
|
-
.option("-c, --current", "display package.json where run-run will be executed")
|
|
11
|
-
.action(async function pkgAction(options) {
|
|
12
|
-
const { appPkg, binPkg } = ctx;
|
|
13
|
-
|
|
14
|
-
const infoObject = options.current ? appPkg.info() : binPkg.info();
|
|
15
|
-
|
|
16
|
-
if (!options.filter) {
|
|
17
|
-
logger.info("%O", infoObject);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const { filter } = options;
|
|
22
|
-
const subInfoObject = get(infoObject.packageJson, filter);
|
|
23
|
-
|
|
24
|
-
if (!subInfoObject) {
|
|
25
|
-
logger.info("No info found");
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
logger.info("%O", { [filter]: subInfoObject });
|
|
30
|
-
});
|
|
31
|
-
}
|