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

Add build:lib command and improve banner
5 changes: 5 additions & 0 deletions .changeset/red-feet-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vlandoss/clibuddy": patch
---

Change exported colors
6 changes: 6 additions & 0 deletions .changeset/slimy-moose-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@vlandoss/localproxy": patch
"@vlandoss/starter": patch
---

Update usage of clibuddy
13 changes: 7 additions & 6 deletions packages/clibuddy/src/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import chalk, { type ChalkInstance } from "chalk";
import supportsColor from "supports-color";

// https://no-color.org/
const colorIsSupported = () => supportsColor.stdout && !process.env.NO_COLOR;
export const colorIsSupported = () => supportsColor.stdout && !process.env.NO_COLOR;

const identity = <T>(x: T) => x;
const safe = (style: ChalkInstance) => (colorIsSupported() ? style : identity);

export const colors = {
blueBright: safe(chalk.blueBright),
redBright: safe(chalk.redBright),
greenBright: safe(chalk.greenBright),
export const colorize = (hex: string) => safe(chalk.hex(hex));

export const palette = {
bold: safe(chalk.bold),
muted: safe(chalk.dim),
italic: safe(chalk.italic),
link: safe(chalk.underline),
muted: safe(chalk.dim),
vland: colorize("#36d399"),
};
8 changes: 4 additions & 4 deletions packages/localproxy/src/ui.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { colors } from "@vlandoss/clibuddy";
import { palette } from "@vlandoss/clibuddy";

export const UI_LOGO = `🛠️ ${colors.bold("localproxy")}`;
export const UI_LOGO = `🛠️ ${palette.bold("localproxy")}`;

export const BANNER_TEXT = `${UI_LOGO}: Simple local development proxy automation\n`;

export const CREDITS_TEXT = `\nAcknowledgment:
- Caddy: for being a powerful proxy server
https://caddyserver.com
${palette.link("https://caddyserver.com")}

- hosts: making it easier to manage host file
https://github.com/xwmx/hosts`;
${palette.link("https://github.com/xwmx/hosts")}`;
1 change: 1 addition & 0 deletions packages/run-run/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"oxlint": "1.50.0",
"oxlint-tsgolint": "0.15.0",
"rimraf": "6.1.3",
"tsdown": "0.21.0-beta.2",
"typescript": "5.9.3"
},
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,8 @@
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots

exports[`should match all root commands: root-command-help 1`] = `
"🦊 R U N - R U N: The CLI toolbox to fullstack common scripts in Variable Land 👊

Usage: rr|run-run [options] <command...>

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

Commands:
config|cfg display the current config 🛠️
check|test:static [options] check format and lint issues 🔍
lint [options] lint the code 🧹
fmt|format [options] format the code 🎨
tsc|typecheck check if TypeScript code is well typed 🎨
clean [options] delete dirty folders or files such as
node_modules, etc 🗑️
pkgs|packages [options] list unique affected packages from list of files
📦
help [command] display help for command

Acknowledgment:
- kcd-scripts: for main inspiration
https://github.com/kentcdodds/kcd-scripts

- peruvian news: in honor to Run Run
https://es.wikipedia.org/wiki/Run_Run
"
`;

exports[`should match all root commands: root-command---help 1`] = `
"🦊 R U N - R U N: The CLI toolbox to fullstack common scripts in Variable Land 👊
"🦊 R U N - R U N v0.0.0-test
The CLI toolbox for Variable Land 👊

Usage: rr|run-run [options] <command...>

Expand All @@ -40,16 +11,15 @@ Options:
-h, --help display help for command

Commands:
config|cfg display the current config 🛠️
check|test:static [options] check format and lint issues 🔍
lint [options] lint the code 🧹
fmt|format [options] format the code 🎨
tsc|typecheck check if TypeScript code is well typed 🎨
clean [options] delete dirty folders or files such as
node_modules, etc 🗑️
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
📦
help [command] display help for command
config|cfg display the current config 🛠️

Acknowledgment:
- kcd-scripts: for main inspiration
Expand All @@ -70,45 +40,22 @@ exports[`should match all root commands: root-command--v 1`] = `
"
`;

exports[`should match help messages for all commands: help-command-run 1`] = `
"Usage: rr run [options] <cmds...>
exports[`should match help messages for all commands: help-command-build:lib 1`] = `
"Usage: rr build:lib [options]

Arguments:
cmds commands to execute concurrently (e.g. 'check tsc')
build a ts project 🏗️ (tsdown)

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

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

display the current config 🛠️

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

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

check format and lint issues 🔍

Options:
-f, --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 check the code.
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]

lint the code 🧹
lint the code 🧹 (biome)

Options:
-c, --check check if the code is valid (default: true)
Expand All @@ -122,7 +69,7 @@ Under the hood, this command uses the biome CLI to lint the code.
exports[`should match help messages for all commands: help-command-fmt 1`] = `
"Usage: rr fmt|format [options]

format the code 🎨
format the code 🎨 (biome)

Options:
-c, --check check if the code is formatted (default: true)
Expand All @@ -133,29 +80,43 @@ Under the hood, this command uses the biome CLI to format the code.
"
`;

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

check format and lint 🔍 (biome)

Options:
-f, --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 check the code.
"
`;

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

check if TypeScript code is well typed 🎨
check if ts code is well typed 🎨 (tsc)

Options:
-h, --help display help for command

Under the hood, this command uses the TypeScript CLI to check 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-clean 1`] = `
"Usage: rr clean [options]

delete dirty folders or files such as node_modules, etc 🗑️
delete dirty folders or files 🗑️ (rimraf)

Options:
--only-dist delete 'dist' folders only
--dry-run outputs the paths that would be deleted
-h, --help display help for command

Under the hood, this command uses the rimraf.js to delete dirty folders or files.
Under the hood, this command uses rimraf to delete dirty folders or files.
"
`;

Expand All @@ -171,6 +132,27 @@ Options:
"
`;

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

display the current config 🛠️

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

exports[`should match help messages for all commands: help-command-run 1`] = `
"Usage: rr run [options] <cmds...>

Arguments:
cmds commands to execute concurrently (e.g. 'check tsc')

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

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

Expand Down
2 changes: 1 addition & 1 deletion packages/run-run/src/program/__tests__/snapshots.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createTestProgram, execCli, mocked } from "#test/helpers";
const { program, ctx } = await createTestProgram();
const $ = ctx.shell.$;

const rootCommands = ["help", "--help", "--version", "-v"];
const rootCommands = ["--help", "--version", "-v"];

afterEach(() => {
mocked($).mockClear();
Expand Down
12 changes: 12 additions & 0 deletions packages/run-run/src/program/commands/build-lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createCommand } from "commander";
import { TOOL_LABELS } from "#/program/ui";
import type { Context } from "#/services/ctx";

export function createBuildLibCommand(ctx: Context) {
return createCommand("build:lib")
.description(`build a ts project 🏗️ (${TOOL_LABELS.TSDOWN})`)
.action(async function buildAction() {
await ctx.shell.$`tsdown`;
})
.addHelpText("afterAll", `\nUnder the hood, this command uses the ${TOOL_LABELS.TSDOWN} CLI to build the project.`);
}
7 changes: 4 additions & 3 deletions packages/run-run/src/program/commands/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { BiomeService } from "#/services/biome";
import type { Context } from "#/services/ctx";

export function createCheckCommand(ctx: Context) {
const biome = new BiomeService(ctx.shell);

return createCommand("check")
.alias("test:static")
.description("check format and lint issues 🔍")
.description(`check format and lint 🔍 (${biome.ui})`)
.option("-f, --fix", "try to fix issues automatically")
.option("--fix-staged", "try to fix staged files only")
.action(async function checkAction(options) {
const biome = new BiomeService(ctx.shell);
const toolCmd = (cmd = "check") => `${cmd} --colors=force`;

if (options.fix) {
Expand All @@ -21,5 +22,5 @@ export function createCheckCommand(ctx: Context) {
await biome.exec(`${toolCmd(isCI ? "ci" : "check")}`);
}
})
.addHelpText("afterAll", "\nUnder the hood, this command uses the biome CLI to check the code.");
.addHelpText("afterAll", `\nUnder the hood, this command uses the ${biome.ui} CLI to check the code.`);
}
5 changes: 3 additions & 2 deletions packages/run-run/src/program/commands/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createCommand } from "commander";
import { type GlobOptions, glob } from "glob";
import { rimraf } from "rimraf";
import { logger } from "#/services/logger";
import { TOOL_LABELS } from "../ui";

type Options = {
onlyDist: boolean;
Expand All @@ -11,7 +12,7 @@ type Options = {

export function createCleanCommand() {
return createCommand("clean")
.description("delete dirty folders or files such as node_modules, etc 🗑️")
.description(`delete dirty folders or files 🗑️ (${TOOL_LABELS.RIMRAF})`)
.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 Expand Up @@ -47,5 +48,5 @@ export function createCleanCommand() {
});
}
})
.addHelpText("afterAll", "\nUnder the hood, this command uses the rimraf.js to delete dirty folders or files.");
.addHelpText("afterAll", `\nUnder the hood, this command uses ${TOOL_LABELS.RIMRAF} to delete dirty folders or files.`);
}
6 changes: 3 additions & 3 deletions packages/run-run/src/program/commands/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { colors } from "@vlandoss/clibuddy";
import { palette } from "@vlandoss/clibuddy";
import { createCommand } from "commander";
import type { Context } from "#/services/ctx";

Expand All @@ -8,8 +8,8 @@ export function createConfigCommand(ctx: Context) {
.description("display the current config 🛠️")
.action(async function configAction() {
const { config, meta } = ctx.config;
console.log(colors.muted("Config:"));
console.log(palette.muted("Config:"));
console.log(config);
console.log(colors.muted(`Loaded from ${meta.filepath ? colors.link(meta.filepath) : "n/a"}`));
console.log(palette.muted(`Loaded from ${meta.filepath ? palette.link(meta.filepath) : "n/a"}`));
});
}
4 changes: 2 additions & 2 deletions packages/run-run/src/program/commands/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export function createFormatCommand(ctx: Context) {

return createCommand("fmt")
.alias("format")
.description("format the code 🎨")
.description(`format the code 🎨 (${toolService.ui})`)
.option("-c, --check", "check if the code is formatted", true)
.option("-f, --fix", "format all the code")
.action(async function formatAction(options: ActionOptions) {
await toolService.format(options);
})
.addHelpText("afterAll", `\nUnder the hood, this command uses the ${toolService.bin} CLI to format the code.`);
.addHelpText("afterAll", `\nUnder the hood, this command uses the ${toolService.ui} CLI to format the code.`);
}
4 changes: 2 additions & 2 deletions packages/run-run/src/program/commands/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export function createLintCommand(ctx: Context) {
const toolService = getToolService(ctx);

return createCommand("lint")
.description("lint the code 🧹")
.description(`lint the code 🧹 (${toolService.ui})`)
.option("-c, --check", "check if the code is valid", true)
.option("-f, --fix", "try to fix all the code")
.action(async function lintAction(options: ActionOptions) {
await toolService.lint(options);
})
.addHelpText("afterAll", `\nUnder the hood, this command uses the ${toolService.bin} CLI to lint the code.`);
.addHelpText("afterAll", `\nUnder the hood, this command uses the ${toolService.ui} CLI to lint the code.`);
}
Loading