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/long-grapes-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vlandoss/run-run": patch
---

Reorder commands
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: variableland/gh-actions/actions/setup-pnpm-bun@main

- name: 💅 Test static
run: pnpm rr check tsc
run: pnpm rr test:static

- name: 🧪 Test unit
run: pnpm test
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ To use this monorepo, you need to have the following tools installed:
3. Run tests:

```bash
pnpm rr check tsc
pnpm test
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ The CLI toolbox for Variable Land 👊
Usage: rr|run-run [options] <command...>

Options:
-v, --version output the version number
-h, --help display help for command
-v, --version output the version number
-h, --help display help for command

Commands:
build:lib build a ts project 🏗️ (tsdown)
lint [options] lint the code 🧹 (biome)
fmt|format [options] format the code 🎨 (biome)
check|test:static [options] check format and lint 🔍 (biome)
tsc|typecheck check if ts code is well typed 🎨 (tsc)
clean [options] delete dirty folders or files 🗑️ (rimraf)
pkgs|packages [options] list unique affected packages from list of files
📦
config|cfg display the current config 🛠️
build:lib build a ts library 🏗️ (tsdown)
jsc|jscheck [options] check format and lint 🔍 (biome)
tsc|tscheck check typescript errors 🧩 (tsc)
lint [options] check & fix lint errors 🔍 (biome)
format [options] check & fix format errors 🎨 (biome)
test:static run static tests 🔬 (run-run)
clean [options] delete dirty files 🗑️ (rimraf)
pkgs [options] list affected packages 📦
config display the current config 🛠️

Acknowledgment:
- kcd-scripts: for main inspiration
Expand All @@ -43,7 +43,8 @@ exports[`should match all root commands: root-command--v 1`] = `
exports[`should match help messages for all commands: help-command-build:lib 1`] = `
"Usage: rr build:lib [options]

build a ts project 🏗️ (tsdown)
Compiles TypeScript code into JavaScript and generates type declaration files,
making it ready for distribution.

Options:
-h, --help display help for command
Expand All @@ -52,64 +53,79 @@ Under the hood, this command uses the tsdown CLI to build the project.
"
`;

exports[`should match help messages for all commands: help-command-lint 1`] = `
"Usage: rr lint [options]
exports[`should match help messages for all commands: help-command-jsc 1`] = `
"Usage: rr jsc|jscheck [options]

lint the code 🧹 (biome)
Checks the code for formatting and linting issues, ensuring it adheres to the
defined style and quality standards.

Options:
-c, --check check if the code is valid (default: true)
-f, --fix try to fix all the code
-h, --help display help for command
--fix try to fix issues automatically
--fix-staged try to fix staged files only
-h, --help display help for command

Under the hood, this command uses the biome CLI to lint the code.
Under the hood, this command uses the biome CLI to check the code.
"
`;

exports[`should match help messages for all commands: help-command-fmt 1`] = `
"Usage: rr fmt|format [options]
exports[`should match help messages for all commands: help-command-tsc 1`] = `
"Usage: rr tsc|tscheck [options]

format the code 🎨 (biome)
Checks the TypeScript code for type errors, ensuring that the code adheres to
the defined type constraints and helps catch potential issues before runtime.

Options:
-c, --check check if the code is formatted (default: true)
-f, --fix format all the code
-h, --help display help for command
-h, --help display help for command

Under the hood, this command uses the biome CLI to format the code.
Under the hood, this command uses the tsc CLI to check the code.
"
`;

exports[`should match help messages for all commands: help-command-check 1`] = `
"Usage: rr check|test:static [options]
exports[`should match help messages for all commands: help-command-lint 1`] = `
"Usage: rr lint [options]

check format and lint 🔍 (biome)
Checks the code for linting issues and optionally fixes them, ensuring it
adheres to the defined quality standards.

Options:
-f, --fix try to fix issues automatically
--fix-staged try to fix staged files only
-h, --help display help for command
-c, --check check if the code is valid (default: true)
--fix try to fix all the code
-h, --help display help for command

Under the hood, this command uses the biome CLI to check the code.
Under the hood, this command uses the biome CLI to lint the code.
"
`;

exports[`should match help messages for all commands: help-command-tsc 1`] = `
"Usage: rr tsc|typecheck [options]
exports[`should match help messages for all commands: help-command-format 1`] = `
"Usage: rr format [options]

check if ts code is well typed 🎨 (tsc)
Checks the code for formatting issues and optionally fixes them, ensuring it
adheres to the defined style standards.

Options:
--fix format all the code
-h, --help display help for command

Under the hood, this command uses the tsc CLI to check the code.
Under the hood, this command uses the biome CLI to format the code.
"
`;

exports[`should match help messages for all commands: help-command-test:static 1`] = `
"Usage: rr test:static [options]

Runs static tests, including linting, formatting checks, and TypeScript type
checking, to ensure code quality and correctness without executing the code.

Options:
-h, --help display help for command
"
`;

exports[`should match help messages for all commands: help-command-clean 1`] = `
"Usage: rr clean [options]

delete dirty folders or files 🗑️ (rimraf)
Deletes generated files and folders such as 'dist', 'node_modules', and lock
files to ensure a clean state.

Options:
--only-dist delete 'dist' folders only
Expand All @@ -121,9 +137,10 @@ Under the hood, this command uses rimraf to delete dirty folders or files.
`;

exports[`should match help messages for all commands: help-command-pkgs 1`] = `
"Usage: rr pkgs|packages [options]
"Usage: rr pkgs [options]

list unique affected packages from list of files 📦
Given a list of files, returns the list of affected packages. Useful to run
commands only on affected packages.

Options:
--files <files...> list of files to check
Expand All @@ -133,9 +150,10 @@ Options:
`;

exports[`should match help messages for all commands: help-command-config 1`] = `
"Usage: rr config|cfg [options]
"Usage: rr config [options]

display the current config 🛠️
Displays the current configuration settings, including their source file path if
available.

Options:
-h, --help display help for command
Expand Down
5 changes: 4 additions & 1 deletion packages/run-run/src/program/commands/build-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import type { Context } from "#/services/ctx";

export function createBuildLibCommand(ctx: Context) {
return createCommand("build:lib")
.description(`build a ts project 🏗️ (${TOOL_LABELS.TSDOWN})`)
.summary(`build a ts library 🏗️ (${TOOL_LABELS.TSDOWN})`)
.description(
"Compiles TypeScript code into JavaScript and generates type declaration files, making it ready for distribution.",
)
.action(async function buildAction() {
await ctx.shell.$`tsdown`;
})
Expand Down
26 changes: 0 additions & 26 deletions packages/run-run/src/program/commands/check.ts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/run-run/src/program/commands/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ type Options = {

export function createCleanCommand() {
return createCommand("clean")
.description(`delete dirty folders or files 🗑️ (${TOOL_LABELS.RIMRAF})`)
.summary(`delete dirty files 🗑️ (${TOOL_LABELS.RIMRAF})`)
.description("Deletes generated files and folders such as 'dist', 'node_modules', and lock files to ensure a clean state.")
.option("--only-dist", "delete 'dist' folders only")
.option("--dry-run", "outputs the paths that would be deleted")
.action(async function cleanCommandAction(options: Options) {
Expand Down
4 changes: 2 additions & 2 deletions packages/run-run/src/program/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { Context } from "#/services/ctx";

export function createConfigCommand(ctx: Context) {
return createCommand("config")
.alias("cfg")
.description("display the current config 🛠️")
.summary("display the current config 🛠️")
.description("Displays the current configuration settings, including their source file path if available.")
.action(async function configAction() {
const { config, meta } = ctx.config;
console.log(palette.muted("Config:"));
Expand Down
12 changes: 6 additions & 6 deletions packages/run-run/src/program/commands/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { OxfmtService } from "#/services/oxfmt";
import type { Formatter } from "#/types/tool";

type ActionOptions = {
check?: boolean;
fix?: boolean;
};

Expand All @@ -22,11 +21,12 @@ function getToolService(ctx: Context): Formatter {
export function createFormatCommand(ctx: Context) {
const toolService = getToolService(ctx);

return createCommand("fmt")
.alias("format")
.description(`format the code 🎨 (${toolService.ui})`)
.option("-c, --check", "check if the code is formatted", true)
.option("-f, --fix", "format all the code")
return createCommand("format")
.summary(`check & fix format errors 🎨 (${toolService.ui})`)
.description(
"Checks the code for formatting issues and optionally fixes them, ensuring it adheres to the defined style standards.",
)
.option("--fix", "format all the code")
.action(async function formatAction(options: ActionOptions) {
await toolService.format(options);
})
Expand Down
27 changes: 27 additions & 0 deletions packages/run-run/src/program/commands/jscheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { createCommand } from "commander";
import { BiomeService } from "#/services/biome";
import type { Context } from "#/services/ctx";
import type { StaticChecker } from "#/types/tool";

type ActionOptions = {
fix?: boolean;
fixStaged?: boolean;
};

export function createJsCheckCommand(ctx: Context) {
const checkerService: StaticChecker = new BiomeService(ctx.shell);

return createCommand("jsc")
.alias("jscheck")
.alias("check")
.summary(`check format and lint 🔍 (${checkerService.ui})`)
.description(
"Checks the code for formatting and linting issues, ensuring it adheres to the defined style and quality standards.",
)
.option("--fix", "try to fix issues automatically")
.option("--fix-staged", "try to fix staged files only")
.action(async function checkAction(options: ActionOptions) {
await checkerService.check(options);
})
.addHelpText("afterAll", `\nUnder the hood, this command uses the ${checkerService.ui} CLI to check the code.`);
}
7 changes: 5 additions & 2 deletions packages/run-run/src/program/commands/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ export function createLintCommand(ctx: Context) {
const toolService = getToolService(ctx);

return createCommand("lint")
.description(`lint the code 🧹 (${toolService.ui})`)
.summary(`check & fix lint errors 🔍 (${toolService.ui})`)
.description(
"Checks the code for linting issues and optionally fixes them, ensuring it adheres to the defined quality standards.",
)
.option("-c, --check", "check if the code is valid", true)
.option("-f, --fix", "try to fix all the code")
.option("--fix", "try to fix all the code")
.action(async function lintAction(options: ActionOptions) {
await toolService.lint(options);
})
Expand Down
6 changes: 4 additions & 2 deletions packages/run-run/src/program/commands/pkgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ type Options = {

export function createPkgsCommand(ctx: Context) {
return createCommand("pkgs")
.alias("packages")
.description("list unique affected packages from list of files 📦")
.summary("list affected packages 📦")
.description(
"Given a list of files, returns the list of affected packages. Useful to run commands only on affected packages.",
)
.addOption(new Option("--files <files...>", "list of files to check"))
.addOption(new Option("--decorator [type]", "type of decorator to use").choices(decorators))
.action(async function pkgsAction({ files, decorator }: Options, cmd: Command) {
Expand Down
14 changes: 14 additions & 0 deletions packages/run-run/src/program/commands/test-static.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createCommand } from "commander";
import { TOOL_LABELS } from "#/program/ui";
import type { Context } from "#/services/ctx";

export function createTestStaticCommand(ctx: Context) {
return createCommand("test:static")
.summary(`run static tests 🔬 (${TOOL_LABELS.RUN_RUN})`)
.description(
"Runs static tests, including linting, formatting checks, and TypeScript type checking, to ensure code quality and correctness without executing the code.",
)
.action(async function testStaticAction() {
await ctx.shell.$`rr jscheck tscheck`;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function typecheckAt({ dir, scripts, log, shell, run }: TypecheckAtOptions
}
}

export function createTypecheckCommand(ctx: Context) {
export function createTsCheckCommand(ctx: Context) {
const {
appPkg,
shell,
Expand All @@ -55,8 +55,11 @@ export function createTypecheckCommand(ctx: Context) {
const toolUi = config.future?.oxc ? TOOL_LABELS.OXLINT : TOOL_LABELS.TSC;

return createCommand("tsc")
.alias("typecheck")
.description(`check if ts code is well typed 🎨 (${toolUi})`)
.alias("tscheck")
.summary(`check typescript errors 🧩 (${toolUi})`)
.description(
"Checks the TypeScript code for type errors, ensuring that the code adheres to the defined type constraints and helps catch potential issues before runtime.",
)
.addHelpText("afterAll", `\nUnder the hood, this command uses the ${toolUi} CLI to check the code.`)
.action(async function typecheckAction() {
const isTsProject = (dir: string) => appPkg.hasFile("tsconfig.json", dir);
Expand Down
Loading