Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(verbose): Disable spinner when verbose. Add trace logs #331

Merged
merged 2 commits into from
Feb 1, 2025
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
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;
}

Check warning on line 21 in src/cli/cliSpinner.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/cliSpinner.ts#L20-L21

Added lines #L20 - L21 were not covered by tests

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

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

Check warning on line 35 in src/cli/cliSpinner.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/cliSpinner.ts#L33-L35

Added lines #L33 - L35 were not covered by tests

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 @@
this.isVerbose = value;
}

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

Check warning on line 13 in src/shared/logger.ts

View check run for this annotation

Codecov / codecov/patch

src/shared/logger.ts#L12-L13

Added lines #L12 - L13 were not covered by tests

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
Loading