@vlandoss/run-run 0.0.16 โ 0.0.17
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 +1 -1
- package/src/program/__tests__/__snapshots__/snapshots.test.ts.snap +60 -42
- package/src/program/commands/build-lib.ts +4 -1
- package/src/program/commands/clean.ts +2 -1
- package/src/program/commands/config.ts +2 -2
- package/src/program/commands/format.ts +6 -6
- package/src/program/commands/jscheck.ts +27 -0
- package/src/program/commands/lint.ts +5 -2
- package/src/program/commands/pkgs.ts +4 -2
- package/src/program/commands/test-static.ts +14 -0
- package/src/program/commands/{typecheck.ts โ tscheck.ts} +6 -3
- package/src/program/index.ts +7 -4
- package/src/program/ui.ts +3 -1
- package/src/services/biome.ts +19 -6
- package/src/services/oxfmt.ts +1 -1
- package/src/services/oxlint.ts +1 -1
- package/src/types/tool.ts +15 -2
- package/src/program/commands/check.ts +0 -26
package/package.json
CHANGED
|
@@ -7,19 +7,19 @@ The CLI toolbox for Variable Land ๐
|
|
|
7
7
|
Usage: rr|run-run [options] <command...>
|
|
8
8
|
|
|
9
9
|
Options:
|
|
10
|
-
-v, --version
|
|
11
|
-
-h, --help
|
|
10
|
+
-v, --version output the version number
|
|
11
|
+
-h, --help display help for command
|
|
12
12
|
|
|
13
13
|
Commands:
|
|
14
|
-
build:lib
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
config
|
|
14
|
+
build:lib build a ts library ๐๏ธ (tsdown)
|
|
15
|
+
jsc|jscheck [options] check format and lint ๐ (biome)
|
|
16
|
+
tsc|tscheck check typescript errors ๐งฉ (tsc)
|
|
17
|
+
lint [options] check & fix lint errors ๐ (biome)
|
|
18
|
+
format [options] check & fix format errors ๐จ (biome)
|
|
19
|
+
test:static run static tests ๐ฌ (run-run)
|
|
20
|
+
clean [options] delete dirty files ๐๏ธ (rimraf)
|
|
21
|
+
pkgs [options] list affected packages ๐ฆ
|
|
22
|
+
config display the current config ๐ ๏ธ
|
|
23
23
|
|
|
24
24
|
Acknowledgment:
|
|
25
25
|
- kcd-scripts: for main inspiration
|
|
@@ -43,7 +43,8 @@ exports[`should match all root commands: root-command--v 1`] = `
|
|
|
43
43
|
exports[`should match help messages for all commands: help-command-build:lib 1`] = `
|
|
44
44
|
"Usage: rr build:lib [options]
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
Compiles TypeScript code into JavaScript and generates type declaration files,
|
|
47
|
+
making it ready for distribution.
|
|
47
48
|
|
|
48
49
|
Options:
|
|
49
50
|
-h, --help display help for command
|
|
@@ -52,64 +53,79 @@ Under the hood, this command uses the tsdown CLI to build the project.
|
|
|
52
53
|
"
|
|
53
54
|
`;
|
|
54
55
|
|
|
55
|
-
exports[`should match help messages for all commands: help-command-
|
|
56
|
-
"Usage: rr
|
|
56
|
+
exports[`should match help messages for all commands: help-command-jsc 1`] = `
|
|
57
|
+
"Usage: rr jsc|jscheck [options]
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
Checks the code for formatting and linting issues, ensuring it adheres to the
|
|
60
|
+
defined style and quality standards.
|
|
59
61
|
|
|
60
62
|
Options:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-h, --help
|
|
63
|
+
--fix try to fix issues automatically
|
|
64
|
+
--fix-staged try to fix staged files only
|
|
65
|
+
-h, --help display help for command
|
|
64
66
|
|
|
65
|
-
Under the hood, this command uses the biome CLI to
|
|
67
|
+
Under the hood, this command uses the biome CLI to check the code.
|
|
66
68
|
"
|
|
67
69
|
`;
|
|
68
70
|
|
|
69
|
-
exports[`should match help messages for all commands: help-command-
|
|
70
|
-
"Usage: rr
|
|
71
|
+
exports[`should match help messages for all commands: help-command-tsc 1`] = `
|
|
72
|
+
"Usage: rr tsc|tscheck [options]
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
Checks the TypeScript code for type errors, ensuring that the code adheres to
|
|
75
|
+
the defined type constraints and helps catch potential issues before runtime.
|
|
73
76
|
|
|
74
77
|
Options:
|
|
75
|
-
-
|
|
76
|
-
-f, --fix format all the code
|
|
77
|
-
-h, --help display help for command
|
|
78
|
+
-h, --help display help for command
|
|
78
79
|
|
|
79
|
-
Under the hood, this command uses the
|
|
80
|
+
Under the hood, this command uses the tsc CLI to check the code.
|
|
80
81
|
"
|
|
81
82
|
`;
|
|
82
83
|
|
|
83
|
-
exports[`should match help messages for all commands: help-command-
|
|
84
|
-
"Usage: rr
|
|
84
|
+
exports[`should match help messages for all commands: help-command-lint 1`] = `
|
|
85
|
+
"Usage: rr lint [options]
|
|
85
86
|
|
|
86
|
-
|
|
87
|
+
Checks the code for linting issues and optionally fixes them, ensuring it
|
|
88
|
+
adheres to the defined quality standards.
|
|
87
89
|
|
|
88
90
|
Options:
|
|
89
|
-
-
|
|
90
|
-
--fix
|
|
91
|
-
-h, --help
|
|
91
|
+
-c, --check check if the code is valid (default: true)
|
|
92
|
+
--fix try to fix all the code
|
|
93
|
+
-h, --help display help for command
|
|
92
94
|
|
|
93
|
-
Under the hood, this command uses the biome CLI to
|
|
95
|
+
Under the hood, this command uses the biome CLI to lint the code.
|
|
94
96
|
"
|
|
95
97
|
`;
|
|
96
98
|
|
|
97
|
-
exports[`should match help messages for all commands: help-command-
|
|
98
|
-
"Usage: rr
|
|
99
|
+
exports[`should match help messages for all commands: help-command-format 1`] = `
|
|
100
|
+
"Usage: rr format [options]
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
Checks the code for formatting issues and optionally fixes them, ensuring it
|
|
103
|
+
adheres to the defined style standards.
|
|
101
104
|
|
|
102
105
|
Options:
|
|
106
|
+
--fix format all the code
|
|
103
107
|
-h, --help display help for command
|
|
104
108
|
|
|
105
|
-
Under the hood, this command uses the
|
|
109
|
+
Under the hood, this command uses the biome CLI to format the code.
|
|
110
|
+
"
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
exports[`should match help messages for all commands: help-command-test:static 1`] = `
|
|
114
|
+
"Usage: rr test:static [options]
|
|
115
|
+
|
|
116
|
+
Runs static tests, including linting, formatting checks, and TypeScript type
|
|
117
|
+
checking, to ensure code quality and correctness without executing the code.
|
|
118
|
+
|
|
119
|
+
Options:
|
|
120
|
+
-h, --help display help for command
|
|
106
121
|
"
|
|
107
122
|
`;
|
|
108
123
|
|
|
109
124
|
exports[`should match help messages for all commands: help-command-clean 1`] = `
|
|
110
125
|
"Usage: rr clean [options]
|
|
111
126
|
|
|
112
|
-
|
|
127
|
+
Deletes generated files and folders such as 'dist', 'node_modules', and lock
|
|
128
|
+
files to ensure a clean state.
|
|
113
129
|
|
|
114
130
|
Options:
|
|
115
131
|
--only-dist delete 'dist' folders only
|
|
@@ -121,9 +137,10 @@ Under the hood, this command uses rimraf to delete dirty folders or files.
|
|
|
121
137
|
`;
|
|
122
138
|
|
|
123
139
|
exports[`should match help messages for all commands: help-command-pkgs 1`] = `
|
|
124
|
-
"Usage: rr pkgs
|
|
140
|
+
"Usage: rr pkgs [options]
|
|
125
141
|
|
|
126
|
-
list
|
|
142
|
+
Given a list of files, returns the list of affected packages. Useful to run
|
|
143
|
+
commands only on affected packages.
|
|
127
144
|
|
|
128
145
|
Options:
|
|
129
146
|
--files <files...> list of files to check
|
|
@@ -133,9 +150,10 @@ Options:
|
|
|
133
150
|
`;
|
|
134
151
|
|
|
135
152
|
exports[`should match help messages for all commands: help-command-config 1`] = `
|
|
136
|
-
"Usage: rr config
|
|
153
|
+
"Usage: rr config [options]
|
|
137
154
|
|
|
138
|
-
|
|
155
|
+
Displays the current configuration settings, including their source file path if
|
|
156
|
+
available.
|
|
139
157
|
|
|
140
158
|
Options:
|
|
141
159
|
-h, --help display help for command
|
|
@@ -4,7 +4,10 @@ import type { Context } from "#/services/ctx";
|
|
|
4
4
|
|
|
5
5
|
export function createBuildLibCommand(ctx: Context) {
|
|
6
6
|
return createCommand("build:lib")
|
|
7
|
-
.
|
|
7
|
+
.summary(`build a ts library ๐๏ธ (${TOOL_LABELS.TSDOWN})`)
|
|
8
|
+
.description(
|
|
9
|
+
"Compiles TypeScript code into JavaScript and generates type declaration files, making it ready for distribution.",
|
|
10
|
+
)
|
|
8
11
|
.action(async function buildAction() {
|
|
9
12
|
await ctx.shell.$`tsdown`;
|
|
10
13
|
})
|
|
@@ -12,7 +12,8 @@ type Options = {
|
|
|
12
12
|
|
|
13
13
|
export function createCleanCommand() {
|
|
14
14
|
return createCommand("clean")
|
|
15
|
-
.
|
|
15
|
+
.summary(`delete dirty files ๐๏ธ (${TOOL_LABELS.RIMRAF})`)
|
|
16
|
+
.description("Deletes generated files and folders such as 'dist', 'node_modules', and lock files to ensure a clean state.")
|
|
16
17
|
.option("--only-dist", "delete 'dist' folders only")
|
|
17
18
|
.option("--dry-run", "outputs the paths that would be deleted")
|
|
18
19
|
.action(async function cleanCommandAction(options: Options) {
|
|
@@ -4,8 +4,8 @@ import type { Context } from "#/services/ctx";
|
|
|
4
4
|
|
|
5
5
|
export function createConfigCommand(ctx: Context) {
|
|
6
6
|
return createCommand("config")
|
|
7
|
-
.
|
|
8
|
-
.description("
|
|
7
|
+
.summary("display the current config ๐ ๏ธ")
|
|
8
|
+
.description("Displays the current configuration settings, including their source file path if available.")
|
|
9
9
|
.action(async function configAction() {
|
|
10
10
|
const { config, meta } = ctx.config;
|
|
11
11
|
console.log(palette.muted("Config:"));
|
|
@@ -5,7 +5,6 @@ import { OxfmtService } from "#/services/oxfmt";
|
|
|
5
5
|
import type { Formatter } from "#/types/tool";
|
|
6
6
|
|
|
7
7
|
type ActionOptions = {
|
|
8
|
-
check?: boolean;
|
|
9
8
|
fix?: boolean;
|
|
10
9
|
};
|
|
11
10
|
|
|
@@ -22,11 +21,12 @@ function getToolService(ctx: Context): Formatter {
|
|
|
22
21
|
export function createFormatCommand(ctx: Context) {
|
|
23
22
|
const toolService = getToolService(ctx);
|
|
24
23
|
|
|
25
|
-
return createCommand("
|
|
26
|
-
.
|
|
27
|
-
.description(
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
return createCommand("format")
|
|
25
|
+
.summary(`check & fix format errors ๐จ (${toolService.ui})`)
|
|
26
|
+
.description(
|
|
27
|
+
"Checks the code for formatting issues and optionally fixes them, ensuring it adheres to the defined style standards.",
|
|
28
|
+
)
|
|
29
|
+
.option("--fix", "format all the code")
|
|
30
30
|
.action(async function formatAction(options: ActionOptions) {
|
|
31
31
|
await toolService.format(options);
|
|
32
32
|
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createCommand } from "commander";
|
|
2
|
+
import { BiomeService } from "#/services/biome";
|
|
3
|
+
import type { Context } from "#/services/ctx";
|
|
4
|
+
import type { StaticChecker } from "#/types/tool";
|
|
5
|
+
|
|
6
|
+
type ActionOptions = {
|
|
7
|
+
fix?: boolean;
|
|
8
|
+
fixStaged?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function createJsCheckCommand(ctx: Context) {
|
|
12
|
+
const checkerService: StaticChecker = new BiomeService(ctx.shell);
|
|
13
|
+
|
|
14
|
+
return createCommand("jsc")
|
|
15
|
+
.alias("jscheck")
|
|
16
|
+
.alias("check")
|
|
17
|
+
.summary(`check format and lint ๐ (${checkerService.ui})`)
|
|
18
|
+
.description(
|
|
19
|
+
"Checks the code for formatting and linting issues, ensuring it adheres to the defined style and quality standards.",
|
|
20
|
+
)
|
|
21
|
+
.option("--fix", "try to fix issues automatically")
|
|
22
|
+
.option("--fix-staged", "try to fix staged files only")
|
|
23
|
+
.action(async function checkAction(options: ActionOptions) {
|
|
24
|
+
await checkerService.check(options);
|
|
25
|
+
})
|
|
26
|
+
.addHelpText("afterAll", `\nUnder the hood, this command uses the ${checkerService.ui} CLI to check the code.`);
|
|
27
|
+
}
|
|
@@ -23,9 +23,12 @@ export function createLintCommand(ctx: Context) {
|
|
|
23
23
|
const toolService = getToolService(ctx);
|
|
24
24
|
|
|
25
25
|
return createCommand("lint")
|
|
26
|
-
.
|
|
26
|
+
.summary(`check & fix lint errors ๐ (${toolService.ui})`)
|
|
27
|
+
.description(
|
|
28
|
+
"Checks the code for linting issues and optionally fixes them, ensuring it adheres to the defined quality standards.",
|
|
29
|
+
)
|
|
27
30
|
.option("-c, --check", "check if the code is valid", true)
|
|
28
|
-
.option("
|
|
31
|
+
.option("--fix", "try to fix all the code")
|
|
29
32
|
.action(async function lintAction(options: ActionOptions) {
|
|
30
33
|
await toolService.lint(options);
|
|
31
34
|
})
|
|
@@ -14,8 +14,10 @@ type Options = {
|
|
|
14
14
|
|
|
15
15
|
export function createPkgsCommand(ctx: Context) {
|
|
16
16
|
return createCommand("pkgs")
|
|
17
|
-
.
|
|
18
|
-
.description(
|
|
17
|
+
.summary("list affected packages ๐ฆ")
|
|
18
|
+
.description(
|
|
19
|
+
"Given a list of files, returns the list of affected packages. Useful to run commands only on affected packages.",
|
|
20
|
+
)
|
|
19
21
|
.addOption(new Option("--files <files...>", "list of files to check"))
|
|
20
22
|
.addOption(new Option("--decorator [type]", "type of decorator to use").choices(decorators))
|
|
21
23
|
.action(async function pkgsAction({ files, decorator }: Options, cmd: Command) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createCommand } from "commander";
|
|
2
|
+
import { TOOL_LABELS } from "#/program/ui";
|
|
3
|
+
import type { Context } from "#/services/ctx";
|
|
4
|
+
|
|
5
|
+
export function createTestStaticCommand(ctx: Context) {
|
|
6
|
+
return createCommand("test:static")
|
|
7
|
+
.summary(`run static tests ๐ฌ (${TOOL_LABELS.RUN_RUN})`)
|
|
8
|
+
.description(
|
|
9
|
+
"Runs static tests, including linting, formatting checks, and TypeScript type checking, to ensure code quality and correctness without executing the code.",
|
|
10
|
+
)
|
|
11
|
+
.action(async function testStaticAction() {
|
|
12
|
+
await ctx.shell.$`rr jscheck tscheck`;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -45,7 +45,7 @@ async function typecheckAt({ dir, scripts, log, shell, run }: TypecheckAtOptions
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export function
|
|
48
|
+
export function createTsCheckCommand(ctx: Context) {
|
|
49
49
|
const {
|
|
50
50
|
appPkg,
|
|
51
51
|
shell,
|
|
@@ -55,8 +55,11 @@ export function createTypecheckCommand(ctx: Context) {
|
|
|
55
55
|
const toolUi = config.future?.oxc ? TOOL_LABELS.OXLINT : TOOL_LABELS.TSC;
|
|
56
56
|
|
|
57
57
|
return createCommand("tsc")
|
|
58
|
-
.alias("
|
|
59
|
-
.
|
|
58
|
+
.alias("tscheck")
|
|
59
|
+
.summary(`check typescript errors ๐งฉ (${toolUi})`)
|
|
60
|
+
.description(
|
|
61
|
+
"Checks the TypeScript code for type errors, ensuring that the code adheres to the defined type constraints and helps catch potential issues before runtime.",
|
|
62
|
+
)
|
|
60
63
|
.addHelpText("afterAll", `\nUnder the hood, this command uses the ${toolUi} CLI to check the code.`)
|
|
61
64
|
.action(async function typecheckAction() {
|
|
62
65
|
const isTsProject = (dir: string) => appPkg.hasFile("tsconfig.json", dir);
|
package/src/program/index.ts
CHANGED
|
@@ -2,15 +2,16 @@ import { getVersion } from "@vlandoss/clibuddy";
|
|
|
2
2
|
import { createCommand } from "commander";
|
|
3
3
|
import { createContext } from "#/services/ctx";
|
|
4
4
|
import { createBuildLibCommand } from "./commands/build-lib";
|
|
5
|
-
import { createCheckCommand } from "./commands/check";
|
|
6
5
|
import { createCleanCommand } from "./commands/clean";
|
|
7
6
|
import { createConfigCommand } from "./commands/config";
|
|
8
7
|
import { createFormatCommand } from "./commands/format";
|
|
8
|
+
import { createJsCheckCommand } from "./commands/jscheck";
|
|
9
9
|
import { createLintCommand } from "./commands/lint";
|
|
10
10
|
import { createPkgsCommand } from "./commands/pkgs";
|
|
11
11
|
import { createRunCommand } from "./commands/run";
|
|
12
|
+
import { createTestStaticCommand } from "./commands/test-static";
|
|
12
13
|
import { createToolsCommand } from "./commands/tools";
|
|
13
|
-
import {
|
|
14
|
+
import { createTsCheckCommand } from "./commands/tscheck";
|
|
14
15
|
import { CREDITS_TEXT, getBannerText } from "./ui";
|
|
15
16
|
|
|
16
17
|
export type Options = {
|
|
@@ -31,10 +32,12 @@ export async function createProgram(options: Options) {
|
|
|
31
32
|
// build
|
|
32
33
|
.addCommand(createBuildLibCommand(ctx))
|
|
33
34
|
// check
|
|
35
|
+
.addCommand(createJsCheckCommand(ctx))
|
|
36
|
+
.addCommand(createTsCheckCommand(ctx))
|
|
34
37
|
.addCommand(createLintCommand(ctx))
|
|
35
38
|
.addCommand(createFormatCommand(ctx))
|
|
36
|
-
|
|
37
|
-
.addCommand(
|
|
39
|
+
// test
|
|
40
|
+
.addCommand(createTestStaticCommand(ctx))
|
|
38
41
|
// misc
|
|
39
42
|
.addCommand(createCleanCommand())
|
|
40
43
|
.addCommand(createPkgsCommand(ctx))
|
package/src/program/ui.ts
CHANGED
|
@@ -13,6 +13,7 @@ const oxlintColor = colorize("#32F3E9");
|
|
|
13
13
|
const oxfmtColor = colorize("#32F3E9");
|
|
14
14
|
const tscColor = colorize("#3178C6");
|
|
15
15
|
const rimrafColor = colorize("#7C7270");
|
|
16
|
+
const runRunColor = colorize("FC7A1E");
|
|
16
17
|
|
|
17
18
|
export const TOOL_LABELS = {
|
|
18
19
|
TSDOWN: tsdownColor("tsdown"),
|
|
@@ -21,6 +22,7 @@ export const TOOL_LABELS = {
|
|
|
21
22
|
OXFMT: oxfmtColor("oxfmt"),
|
|
22
23
|
TSC: tscColor("tsc"),
|
|
23
24
|
RIMRAF: rimrafColor("rimraf"),
|
|
25
|
+
RUN_RUN: runRunColor("run-run"),
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
export function getBannerText(version: string) {
|
|
@@ -36,7 +38,7 @@ export function getBannerText(version: string) {
|
|
|
36
38
|
|
|
37
39
|
const FOX_COLORS = {
|
|
38
40
|
BLACK: colorize("#39393A"),
|
|
39
|
-
ORANGE:
|
|
41
|
+
ORANGE: runRunColor,
|
|
40
42
|
WHITE: colorize("#FFFFFF"),
|
|
41
43
|
};
|
|
42
44
|
|
package/src/services/biome.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ShellService } from "@vlandoss/clibuddy";
|
|
2
|
+
import isCI from "is-ci";
|
|
2
3
|
import { TOOL_LABELS } from "#/program/ui";
|
|
3
|
-
import type { FormatOptions, Formatter, Linter, LintOptions } from "#/types/tool";
|
|
4
|
+
import type { FormatOptions, Formatter, Linter, LintOptions, StaticChecker, StaticCheckerOptions } from "#/types/tool";
|
|
4
5
|
import { ToolService } from "./tool";
|
|
5
6
|
|
|
6
|
-
export class BiomeService extends ToolService implements Formatter, Linter {
|
|
7
|
+
export class BiomeService extends ToolService implements Formatter, Linter, StaticChecker {
|
|
7
8
|
constructor(shellService: ShellService) {
|
|
8
9
|
super({ bin: "biome", ui: TOOL_LABELS.BIOME, shellService });
|
|
9
10
|
}
|
|
@@ -13,22 +14,34 @@ export class BiomeService extends ToolService implements Formatter, Linter {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
async format(options: FormatOptions) {
|
|
16
|
-
const commonOptions = "format --no-errors-on-unmatched
|
|
17
|
+
const commonOptions = "format --colors=force --no-errors-on-unmatched";
|
|
17
18
|
|
|
18
19
|
if (options.fix) {
|
|
19
20
|
await this.exec(`${commonOptions} --fix`);
|
|
20
|
-
} else
|
|
21
|
+
} else {
|
|
21
22
|
await this.exec(`${commonOptions}`);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
async lint(options: LintOptions) {
|
|
26
|
-
const commonOptions = "check --colors=force --formatter-enabled=false";
|
|
27
|
+
const commonOptions = "check --colors=force --no-errors-on-unmatched --formatter-enabled=false";
|
|
27
28
|
|
|
28
29
|
if (options.fix) {
|
|
29
30
|
await this.exec(`${commonOptions} --fix --unsafe`);
|
|
30
|
-
} else
|
|
31
|
+
} else {
|
|
31
32
|
await this.exec(`${commonOptions}`);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
|
|
36
|
+
async check(options: StaticCheckerOptions): Promise<void> {
|
|
37
|
+
const commonOptions = (cmd = "check") => `${cmd} --colors=force --no-errors-on-unmatched`;
|
|
38
|
+
|
|
39
|
+
if (options.fix) {
|
|
40
|
+
await this.exec(`${commonOptions()} --fix`);
|
|
41
|
+
} else if (options.fixStaged) {
|
|
42
|
+
await this.exec(`${commonOptions()} --fix --staged`);
|
|
43
|
+
} else {
|
|
44
|
+
await this.exec(`${commonOptions(isCI ? "ci" : "check")}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
34
47
|
}
|
package/src/services/oxfmt.ts
CHANGED
package/src/services/oxlint.ts
CHANGED
package/src/types/tool.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
export type FormatOptions = {
|
|
2
|
-
check?: boolean;
|
|
3
2
|
fix?: boolean;
|
|
4
3
|
};
|
|
5
4
|
|
|
6
5
|
export type LintOptions = {
|
|
7
|
-
check?: boolean;
|
|
8
6
|
fix?: boolean;
|
|
9
7
|
};
|
|
10
8
|
|
|
9
|
+
export type StaticCheckerOptions = {
|
|
10
|
+
fix?: boolean;
|
|
11
|
+
fixStaged?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
11
14
|
export type Formatter = {
|
|
12
15
|
bin: string;
|
|
13
16
|
ui: string;
|
|
@@ -19,3 +22,13 @@ export type Linter = {
|
|
|
19
22
|
ui: string;
|
|
20
23
|
lint(options: LintOptions): Promise<void>;
|
|
21
24
|
};
|
|
25
|
+
|
|
26
|
+
export type StaticChecker = {
|
|
27
|
+
bin: string;
|
|
28
|
+
ui: string;
|
|
29
|
+
check(options: StaticCheckerOptions): Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type TypeChecker = {
|
|
33
|
+
check(): Promise<void>;
|
|
34
|
+
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createCommand } from "commander";
|
|
2
|
-
import isCI from "is-ci";
|
|
3
|
-
import { BiomeService } from "#/services/biome";
|
|
4
|
-
import type { Context } from "#/services/ctx";
|
|
5
|
-
|
|
6
|
-
export function createCheckCommand(ctx: Context) {
|
|
7
|
-
const biome = new BiomeService(ctx.shell);
|
|
8
|
-
|
|
9
|
-
return createCommand("check")
|
|
10
|
-
.alias("test:static")
|
|
11
|
-
.description(`check format and lint ๐ (${biome.ui})`)
|
|
12
|
-
.option("-f, --fix", "try to fix issues automatically")
|
|
13
|
-
.option("--fix-staged", "try to fix staged files only")
|
|
14
|
-
.action(async function checkAction(options) {
|
|
15
|
-
const toolCmd = (cmd = "check") => `${cmd} --colors=force`;
|
|
16
|
-
|
|
17
|
-
if (options.fix) {
|
|
18
|
-
await biome.exec(`${toolCmd()} --fix`);
|
|
19
|
-
} else if (options.fixStaged) {
|
|
20
|
-
await biome.exec(`${toolCmd()} --no-errors-on-unmatched --fix --staged`);
|
|
21
|
-
} else {
|
|
22
|
-
await biome.exec(`${toolCmd(isCI ? "ci" : "check")}`);
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
.addHelpText("afterAll", `\nUnder the hood, this command uses the ${biome.ui} CLI to check the code.`);
|
|
26
|
-
}
|