Skip to content

Commit

Permalink
Merge pull request #331 from yamadashy/feat/verbose-no-spinner
Browse files Browse the repository at this point in the history
feat(verbose): Disable spinner when verbose. Add trace logs
  • Loading branch information
yamadashy authored Feb 1, 2025
2 parents 8f9209c + bc0033b commit 532954f
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ npm install
To run Repomix locally:

```bash
npm run cli-run
npm run repomix
```

### Docker Usage
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"lint-secretlint": "secretlint \"**/*\" --secretlintignore .gitignore",
"test": "vitest",
"test-coverage": "vitest run --coverage",
"cli-run": "npm run build && node --trace-warnings bin/repomix.cjs",
"repomix": "npm run build && node --trace-warnings bin/repomix.cjs",
"repomix-src": "npm run repomix -- --include 'src,tests'",
"repomix-website": "npm run repomix -- --include 'website'",
"npm-publish": "npm run lint && npm run test-coverage && npm run build && npm publish",
"npm-release-patch": "npm version patch && npm run npm-publish",
"npm-release-minor": "npm version minor && npm run npm-publish",
Expand Down
11 changes: 11 additions & 0 deletions src/cli/cliSpinner.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import cliSpinners from 'cli-spinners';
import logUpdate from 'log-update';
import pc from 'picocolors';
import { logger } from '../shared/logger.js';

class Spinner {
private spinner = cliSpinners.dots;
private message: string;
private currentFrame = 0;
private interval: ReturnType<typeof setInterval> | null = null;
private isEnabled: boolean;

constructor(message: string) {
this.message = message;
this.isEnabled = !logger.isVerboseEnabled();
}

start(): void {
if (!this.isEnabled) {
return;
}

const frames = this.spinner.frames;
const framesLength = frames.length;
this.interval = setInterval(() => {
Expand All @@ -23,6 +30,10 @@ class Spinner {
}

update(message: string): void {
if (!this.isEnabled) {
return;
}

this.message = message;
}

Expand Down
1 change: 1 addition & 0 deletions src/core/file/fileProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const processFiles = async (
runTask(task).then((result) => {
completedTasks++;
progressCallback(`Processing file... (${completedTasks}/${totalTasks}) ${pc.dim(task.rawFile.path)}`);
logger.trace(`Processing file... (${completedTasks}/${totalTasks}) ${task.rawFile.path}`);
return result;
}),
),
Expand Down
1 change: 1 addition & 0 deletions src/core/metrics/calculateAllFileMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const calculateAllFileMetrics = async (
runTask(task).then((result) => {
completedTasks++;
progressCallback(`Calculating metrics... (${completedTasks}/${task.totalFiles}) ${pc.dim(task.file.path)}`);
logger.trace(`Calculating metrics... (${completedTasks}/${task.totalFiles}) ${task.file.path}`);
return result;
}),
),
Expand Down
1 change: 1 addition & 0 deletions src/core/security/securityCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const runSecurityCheck = async (
runTask(task).then((result) => {
completedTasks++;
progressCallback(`Running security check... (${completedTasks}/${totalTasks}) ${pc.dim(task.filePath)}`);
logger.trace(`Running security check... (${completedTasks}/${totalTasks}) ${task.filePath}`);
return result;
}),
),
Expand Down
4 changes: 4 additions & 0 deletions src/shared/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class Logger {
this.isVerbose = value;
}

isVerboseEnabled(): boolean {
return this.isVerbose;
}

error(...args: unknown[]) {
console.error(pc.red(this.formatArgs(args)));
}
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/en/guide/development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npm install

```bash
# Run CLI
npm run cli-run
npm run repomix

# Run tests
npm run test
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/en/guide/development/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cd repomix
npm install

# Run CLI
npm run cli-run
npm run repomix
```

## Docker Development
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/es/guide/development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npm install

```bash
# Ejecutar CLI
npm run cli-run
npm run repomix

# Ejecutar pruebas
npm run test
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/es/guide/development/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cd repomix
npm install

# Ejecutar CLI
npm run cli-run
npm run repomix
```

## Desarrollo con Docker
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/ja/guide/development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npm install

```bash
# CLIを実行
npm run cli-run
npm run repomix

# テストを実行
npm run test
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/ja/guide/development/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cd repomix
npm install

# CLIの実行
npm run cli-run
npm run repomix
```

## Docker開発
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/ko/guide/development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npm install

```bash
# CLI 실행
npm run cli-run
npm run repomix

# 테스트 실행
npm run test
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/ko/guide/development/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cd repomix
npm install

# CLI 실행
npm run cli-run
npm run repomix
```

## Docker 개발
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/pt-br/guide/development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npm install

```bash
# Executar CLI
npm run cli-run
npm run repomix

# Executar testes
npm run test
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/pt-br/guide/development/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cd repomix
npm install

# Executar CLI
npm run cli-run
npm run repomix
```

## Desenvolvimento com Docker
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/zh-cn/guide/development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npm install

```bash
# 运行 CLI
npm run cli-run
npm run repomix

# 运行测试
npm run test
Expand Down
2 changes: 1 addition & 1 deletion website/client/src/zh-cn/guide/development/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cd repomix
npm install

# 运行 CLI
npm run cli-run
npm run repomix
```

## Docker 开发环境
Expand Down

0 comments on commit 532954f

Please sign in to comment.