@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vlandoss/run-run",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
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": {
@@ -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 output the version number
11
- -h, --help display help for command
10
+ -v, --version output the version number
11
+ -h, --help display help for command
12
12
 
13
13
  Commands:
14
- build:lib build a ts project ๐Ÿ—๏ธ (tsdown)
15
- lint [options] lint the code ๐Ÿงน (biome)
16
- fmt|format [options] format the code ๐ŸŽจ (biome)
17
- check|test:static [options] check format and lint ๐Ÿ” (biome)
18
- tsc|typecheck check if ts code is well typed ๐ŸŽจ (tsc)
19
- clean [options] delete dirty folders or files ๐Ÿ—‘๏ธ (rimraf)
20
- pkgs|packages [options] list unique affected packages from list of files
21
- ๐Ÿ“ฆ
22
- config|cfg display the current 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
- build a ts project ๐Ÿ—๏ธ (tsdown)
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-lint 1`] = `
56
- "Usage: rr lint [options]
56
+ exports[`should match help messages for all commands: help-command-jsc 1`] = `
57
+ "Usage: rr jsc|jscheck [options]
57
58
 
58
- lint the code ๐Ÿงน (biome)
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
- -c, --check check if the code is valid (default: true)
62
- -f, --fix try to fix all the code
63
- -h, --help display help for command
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 lint the code.
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-fmt 1`] = `
70
- "Usage: rr fmt|format [options]
71
+ exports[`should match help messages for all commands: help-command-tsc 1`] = `
72
+ "Usage: rr tsc|tscheck [options]
71
73
 
72
- format the code ๐ŸŽจ (biome)
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
- -c, --check check if the code is formatted (default: true)
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 biome CLI to format the code.
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-check 1`] = `
84
- "Usage: rr check|test:static [options]
84
+ exports[`should match help messages for all commands: help-command-lint 1`] = `
85
+ "Usage: rr lint [options]
85
86
 
86
- check format and lint ๐Ÿ” (biome)
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
- -f, --fix try to fix issues automatically
90
- --fix-staged try to fix staged files only
91
- -h, --help display help for command
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 check the code.
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-tsc 1`] = `
98
- "Usage: rr tsc|typecheck [options]
99
+ exports[`should match help messages for all commands: help-command-format 1`] = `
100
+ "Usage: rr format [options]
99
101
 
100
- check if ts code is well typed ๐ŸŽจ (tsc)
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 tsc CLI to check the code.
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
- delete dirty folders or files ๐Ÿ—‘๏ธ (rimraf)
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|packages [options]
140
+ "Usage: rr pkgs [options]
125
141
 
126
- list unique affected packages from list of files ๐Ÿ“ฆ
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|cfg [options]
153
+ "Usage: rr config [options]
137
154
 
138
- display the current config ๐Ÿ› ๏ธ
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
- .description(`build a ts project ๐Ÿ—๏ธ (${TOOL_LABELS.TSDOWN})`)
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
- .description(`delete dirty folders or files ๐Ÿ—‘๏ธ (${TOOL_LABELS.RIMRAF})`)
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
- .alias("cfg")
8
- .description("display the current config ๐Ÿ› ๏ธ")
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("fmt")
26
- .alias("format")
27
- .description(`format the code ๐ŸŽจ (${toolService.ui})`)
28
- .option("-c, --check", "check if the code is formatted", true)
29
- .option("-f, --fix", "format all the code")
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
- .description(`lint the code ๐Ÿงน (${toolService.ui})`)
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("-f, --fix", "try to fix all the code")
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
- .alias("packages")
18
- .description("list unique affected packages from list of files ๐Ÿ“ฆ")
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 createTypecheckCommand(ctx: Context) {
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("typecheck")
59
- .description(`check if ts code is well typed ๐ŸŽจ (${toolUi})`)
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);
@@ -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 { createTypecheckCommand } from "./commands/typecheck";
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
- .addCommand(createCheckCommand(ctx))
37
- .addCommand(createTypecheckCommand(ctx))
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: colorize("FC7A1e"),
41
+ ORANGE: runRunColor,
40
42
  WHITE: colorize("#FFFFFF"),
41
43
  };
42
44
 
@@ -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 --colors=force";
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 if (options.check) {
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 if (options.check) {
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
  }
@@ -17,7 +17,7 @@ export class OxfmtService extends ToolService implements Formatter {
17
17
 
18
18
  if (options.fix) {
19
19
  await this.exec(`${commonOptions} --fix`);
20
- } else if (options.check) {
20
+ } else {
21
21
  await this.exec(`${commonOptions} --check`);
22
22
  }
23
23
  }
@@ -17,7 +17,7 @@ export class OxlintService extends ToolService implements Linter {
17
17
 
18
18
  if (options.fix) {
19
19
  await this.exec(`${commonOptions} --fix`);
20
- } else if (options.check) {
20
+ } else {
21
21
  await this.exec(`${commonOptions} --check`);
22
22
  }
23
23
  }
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
- }