rbin-task-flow 1.12.0 → 1.14.0
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/.cursor/rules/task_check.mdc +38 -0
- package/.cursor/rules/task_execution.mdc +2 -0
- package/.cursor/rules/task_improve_changes.mdc +51 -0
- package/.task-flow/README.md +13 -0
- package/AGENTS.md +3 -1
- package/CLAUDE.md +2 -0
- package/README.md +6 -0
- package/bin/cli.js +22 -0
- package/lib/audit.js +44 -0
- package/lib/check.js +113 -0
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Run lint fix when available, then build the current project
|
|
3
|
+
globs: **/*
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# task-flow: check
|
|
8
|
+
|
|
9
|
+
When the user runs `task-flow: check`:
|
|
10
|
+
|
|
11
|
+
1. **Detect project scripts**: Read `package.json` and look for lint and build scripts.
|
|
12
|
+
2. **Run lint first**: Prefer a fix-capable lint command if present (`lint:fix`, `lint-fix`, or equivalent). If there is only `lint`, run it and fix the reported issues.
|
|
13
|
+
3. **Run build next**: If a `build` script exists, run it after lint succeeds.
|
|
14
|
+
4. **Fix failures**: If lint or build fails, fix the issues and re-run until they pass.
|
|
15
|
+
5. **Keep scope local**: This command is only for project checks. It does not run the coding-standards audit and does not change task files by itself.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## How to execute
|
|
20
|
+
|
|
21
|
+
- **Step 1**: Read `package.json` and identify which package manager and scripts the project uses.
|
|
22
|
+
- **Step 2**: Run lint first, preferring an autofix variant when one exists.
|
|
23
|
+
- **Step 3**: Fix any lint errors or warnings that should be resolved now.
|
|
24
|
+
- **Step 4**: Run build and fix any failures.
|
|
25
|
+
- **Step 5**: Report what ran, what was skipped, and whether the project is passing.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Natural language
|
|
30
|
+
|
|
31
|
+
- **FAST FORMAT**: `task-flow: check` or `task-flow check`
|
|
32
|
+
- "run checks", "run lint and build", "validate this project" → same command
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Principle
|
|
37
|
+
|
|
38
|
+
> **Use `task-flow: check` to make the current project pass its local validation steps before reviewing or committing changes.**
|
|
@@ -22,6 +22,8 @@ alwaysApply: true
|
|
|
22
22
|
- `task-flow: sync` - Sync new tasks from tasks.input.txt
|
|
23
23
|
- `task-flow: think` - Analyze codebase and suggest new tasks
|
|
24
24
|
- `task-flow: audit` - Audit codebase against coding standards and suggest incremental improvements
|
|
25
|
+
- `task-flow: check` - Run lint fix when available, then build the current project
|
|
26
|
+
- `task-flow: improve changes` - Audit only files changed in the current diff against `HEAD`
|
|
25
27
|
- `task-flow: run next X` - Work on next X subtasks sequentially
|
|
26
28
|
- `task-flow: run X` - Work on all pending subtasks of task X (simplified - no "task" needed)
|
|
27
29
|
- `task-flow: run X,Y` - Work on multiple tasks (comma-separated)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Audit only files changed in the current diff against coding standards
|
|
3
|
+
globs: **/*
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# task-flow: improve changes
|
|
8
|
+
|
|
9
|
+
When the user runs `task-flow: improve changes`:
|
|
10
|
+
|
|
11
|
+
1. **Audit current changes only**: Do the **same as** [task-flow: audit](mdc:.cursor/rules/task_audit.mdc) (codebase audit against [coding_standards.mdc](mdc:.cursor/rules/coding_standards.mdc)), but **restricted to files that were changed and not yet committed**.
|
|
12
|
+
2. **Do not run project checks here**: Lint fix and build now belong to [task-flow: check](mdc:.cursor/rules/task_check.mdc).
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Scope: uncommitted files only
|
|
17
|
+
|
|
18
|
+
1. **Get the list of uncommitted files** (read-only git; do not run `git add`/`git commit`). Use the list of paths from:
|
|
19
|
+
- Modified but not staged: `git diff --name-only`
|
|
20
|
+
- Staged but not committed: `git diff --name-only --cached`
|
|
21
|
+
- Combined: all files that differ from `HEAD` → `git diff --name-only HEAD`
|
|
22
|
+
- **Use** `git diff --name-only HEAD` so that both unstaged and staged (but uncommitted) changes are included.
|
|
23
|
+
|
|
24
|
+
2. If there are **no uncommitted changes**, tell the user and stop.
|
|
25
|
+
|
|
26
|
+
3. **Restrict the audit to those paths**: when performing the steps from [task_audit.mdc](mdc:.cursor/rules/task_audit.mdc) (explore, score, report, ask what to adopt, generate tasks), consider **only** the files in the list above. Do not score or suggest improvements for files that were not changed.
|
|
27
|
+
|
|
28
|
+
4. **Same principles as audit**: non-destructive, incremental, suggest improvements and let the user choose. Only the scope is different: uncommitted files only.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## How to execute
|
|
33
|
+
|
|
34
|
+
- **Step 1**: Obtain uncommitted file list (e.g. run `git diff --name-only HEAD` or use your tools to get the list). If empty, stop.
|
|
35
|
+
- **Step 2**: Read and analyze **only** the uncommitted files (and their immediate context if needed).
|
|
36
|
+
- **Step 3**: For that subset, apply the same categories and scoring as in task-flow: audit (folder structure, thin app/, naming, cn(), forms, etc.) and note which of those categories are relevant to the changed files.
|
|
37
|
+
- **Step 4**: Present findings and suggested improvements **only for the uncommitted files**.
|
|
38
|
+
- **Step 5**: Ask which improvements the user wants; generate tasks or concrete edits only for the selected items, touching only uncommitted files where possible.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Natural language
|
|
43
|
+
|
|
44
|
+
- **FAST FORMAT**: `task-flow: improve changes` or `task-flow improve changes`
|
|
45
|
+
- "improve my changes", "audit my uncommitted changes", "check my changes against standards" → same command
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Principle
|
|
50
|
+
|
|
51
|
+
> **Use `task-flow: improve changes` as a scoped audit for the current diff against `HEAD`. Use `task-flow: check` separately when you want lint/build validation.**
|
package/.task-flow/README.md
CHANGED
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
| `task-flow: refactor X` | Refactors specific task(s) (e.g., `task-flow: refactor 1` or `task-flow: refactor 10,11` or `task-flow: refactor all`) |
|
|
16
16
|
| `task-flow: estimate X` | Estimates time for task X (e.g., `task-flow: estimate 1` or `task-flow: estimate 10,11`) |
|
|
17
17
|
| `task-flow: report X` | Generates implementation report for task X (e.g., `task-flow: report 1` or `task-flow: report 10,11`) |
|
|
18
|
+
| `task-flow: audit` | Audits codebase against coding standards and suggests incremental improvements |
|
|
19
|
+
| `task-flow: improve changes` | Run lint fix + build (fix issues), then audit only uncommitted files |
|
|
20
|
+
| `rbin-task-flow audit` | **(CLI)** Lists files with unstaged changes (not yet `git add`) |
|
|
18
21
|
|
|
19
22
|
**See complete details below ↓**
|
|
20
23
|
|
|
@@ -36,6 +39,16 @@ Analyzes code and suggests new tasks. Asks before adding to `tasks.input.txt`.
|
|
|
36
39
|
### `task-flow: status`
|
|
37
40
|
Shows current status of tasks and subtasks from the `tasks.status.md` file.
|
|
38
41
|
|
|
42
|
+
### `task-flow: audit`
|
|
43
|
+
Audits the **entire codebase** against the coding standards in [coding_standards.mdc](.cursor/rules/coding_standards.mdc). Non-destructive: reports gaps and suggests incremental improvements; the user chooses what to adopt. See [task_audit.mdc](.cursor/rules/task_audit.mdc) for the full flow.
|
|
44
|
+
|
|
45
|
+
### `task-flow: improve changes`
|
|
46
|
+
1. **Lint and build**: Run lint fix if the project has it; fix any lint warnings or errors; run build and fix until it passes.
|
|
47
|
+
2. **Audit uncommitted only**: Same as **task-flow: audit**, but **only for files that were changed and not yet committed** (unstaged + staged). Use before committing to align the current change set with coding standards. The AI obtains the list of uncommitted files and runs the audit flow restricted to those paths.
|
|
48
|
+
|
|
49
|
+
### `rbin-task-flow audit` (CLI only)
|
|
50
|
+
Lists **unstaged** file paths (modified but not yet `git add`). Run in the project root: `rbin-task-flow audit`. Option: `-p, --path <path>`.
|
|
51
|
+
|
|
39
52
|
---
|
|
40
53
|
|
|
41
54
|
## Commands with Task ID
|
package/AGENTS.md
CHANGED
|
@@ -29,8 +29,10 @@ This repo follows the same development norms as in `.cursor/rules/` and `CLAUDE.
|
|
|
29
29
|
- **Task flow** always means **RBIN Task Flow**.
|
|
30
30
|
- Tasks: `.task-flow/tasks.input.txt` (format: `- Task description`).
|
|
31
31
|
- Status: `.task-flow/tasks.status.md` and `.task-flow/.internal/status.json`.
|
|
32
|
-
- **Commands** to support: `task-flow: sync`, `task-flow: think`, `task-flow: audit`, `task-flow: status`, `task-flow: run next X`, `task-flow: run X` (or `X,Y` / `all`), `task-flow: review X`, `task-flow: refactor X`, `task-flow: estimate X`, `task-flow: report X`.
|
|
32
|
+
- **Commands** to support: `task-flow: sync`, `task-flow: think`, `task-flow: audit`, `task-flow: check`, `task-flow: improve changes`, `task-flow: status`, `task-flow: run next X`, `task-flow: run X` (or `X,Y` / `all`), `task-flow: review X`, `task-flow: refactor X`, `task-flow: estimate X`, `task-flow: report X`.
|
|
33
33
|
- When running `task-flow: audit`: scan the codebase, score it against `.cursor/rules/coding_standards.mdc`, present a report, and ask the user which improvements to adopt — never impose changes.
|
|
34
|
+
- When running `task-flow: check`: run lint fix if present and fix lint warnings/errors; run build and fix until it passes.
|
|
35
|
+
- When running `task-flow: improve changes`: same as audit but only for files changed and not yet committed (obtain list via `git diff --name-only HEAD`, then audit only those paths).
|
|
34
36
|
- When running subtasks: read `.task-flow/.internal/tasks.json` and `status.json`, implement, then update `status.json` and `tasks.status.md` (mark done, refresh summary).
|
|
35
37
|
- Use context from `.task-flow/contexts/` when subtask instructions reference it.
|
|
36
38
|
|
package/CLAUDE.md
CHANGED
|
@@ -22,6 +22,8 @@ This project uses RBIN Task Flow for task management:
|
|
|
22
22
|
- `task-flow: sync` - Synchronize tasks from tasks.input.txt
|
|
23
23
|
- `task-flow: think` - Analyze code and suggest new tasks
|
|
24
24
|
- `task-flow: audit` - Audit codebase against coding standards and suggest incremental improvements
|
|
25
|
+
- `task-flow: check` - Run lint fix when available, then build the current project
|
|
26
|
+
- `task-flow: improve changes` - Audit only files changed in the current diff against `HEAD`
|
|
25
27
|
- `task-flow: status` - View current task status
|
|
26
28
|
- `task-flow: run next X` - Work on next X subtasks
|
|
27
29
|
- `task-flow: run X` - Execute all pending subtasks of task X (simplified - no "task" needed)
|
package/README.md
CHANGED
|
@@ -73,6 +73,7 @@ rbin-task-flow init # Inicializa no projeto atual
|
|
|
73
73
|
rbin-task-flow update # Atualiza configurações
|
|
74
74
|
rbin-task-flow version-check # Verifica atualizações de modelos
|
|
75
75
|
rbin-task-flow info # Mostra informações
|
|
76
|
+
rbin-task-flow check # Roda lint/fix e build quando existirem
|
|
76
77
|
rbin-task-flow estimate <ids> # Estima tempo (ex: "1" ou "1,2" ou "all")
|
|
77
78
|
rbin-task-flow report <ids> # Gera relatório (ex: "1" ou "1,2" ou "all")
|
|
78
79
|
```
|
|
@@ -86,6 +87,8 @@ Após inicializar, use estes comandos na IA (Cursor/Claude) para gerenciar taref
|
|
|
86
87
|
| `task-flow: sync` | **Sincroniza** tarefas do arquivo texto com o sistema | Mantém tudo sincronizado automaticamente - adiciona novas, remove deletadas, preserva seu progresso |
|
|
87
88
|
| `task-flow: think` | **Descobre** tarefas que você esqueceu | Analisa código e sugere tarefas que faltam (testes, refatoração, documentação) |
|
|
88
89
|
| `task-flow: audit` | **Avalia** o quanto o código bate com os padrões de codificação | Analisa a codebase, dá um score por categoria e pergunta quais melhorias você quer adotar — sem impor nada |
|
|
90
|
+
| `task-flow: check` | **Valida** lint e build antes de revisar ou commitar | Roda lint com fix quando disponível e depois build, corrigindo problemas do projeto atual |
|
|
91
|
+
| `task-flow: improve changes` | **Audita** só o diff atual | Faz o mesmo audit de padrões, mas restrito aos arquivos alterados em relação ao `HEAD` |
|
|
89
92
|
| `task-flow: status` | **Visualiza** o progresso rapidamente | Vê resumo com tasks completas, em andamento e quantas subtarefas faltam |
|
|
90
93
|
| `task-flow: run next X` | **Automatiza** o trabalho nas próximas subtarefas | A IA trabalha nas próximas X subtarefas sequencialmente, você só acompanha |
|
|
91
94
|
| `task-flow: run X` | **Completa** uma tarefa inteira de uma vez | Executa todas as subtarefas de uma tarefa específica (permite trabalho paralelo) |
|
|
@@ -417,6 +420,7 @@ rbin-task-flow init # Initialize in current project
|
|
|
417
420
|
rbin-task-flow update # Update configurations
|
|
418
421
|
rbin-task-flow version-check # Check for model updates
|
|
419
422
|
rbin-task-flow info # Show information
|
|
423
|
+
rbin-task-flow check # Run lint/fix and build when available
|
|
420
424
|
rbin-task-flow estimate <ids> # Estimate time (e.g., "1" or "1,2" or "all")
|
|
421
425
|
rbin-task-flow report <ids> # Generate report (e.g., "1" or "1,2" or "all")
|
|
422
426
|
```
|
|
@@ -430,6 +434,8 @@ After initializing, use these commands in your AI (Cursor/Claude) to automatical
|
|
|
430
434
|
| `task-flow: sync` | **Sync** tasks from text file with system | Keeps everything synchronized automatically - adds new, removes deleted, preserves your progress |
|
|
431
435
|
| `task-flow: think` | **Discover** tasks you forgot | Analyzes code and suggests missing tasks (tests, refactoring, documentation) |
|
|
432
436
|
| `task-flow: audit` | **Evaluate** how well your code matches coding standards | Scans the codebase, scores it by category and asks which improvements you want to adopt — never imposes changes |
|
|
437
|
+
| `task-flow: check` | **Validate** lint and build before review or commit | Runs lint with autofix when available and then build, fixing current-project issues first |
|
|
438
|
+
| `task-flow: improve changes` | **Audit** only the current diff | Runs the same standards audit, but restricted to files changed relative to `HEAD` |
|
|
433
439
|
| `task-flow: status` | **Visualize** progress quickly | See summary with completed tasks, in progress, and remaining subtasks |
|
|
434
440
|
| `task-flow: run next X` | **Automate** work on next subtasks | AI works on next X subtasks sequentially, you just follow along |
|
|
435
441
|
| `task-flow: run X` | **Complete** an entire task at once | Executes all subtasks of a specific task (allows parallel work) |
|
package/bin/cli.js
CHANGED
|
@@ -6,6 +6,8 @@ const { installInProject } = require('../lib/install');
|
|
|
6
6
|
const { checkVersionUpdates } = require('../lib/version');
|
|
7
7
|
const { estimateTask } = require('../lib/estimate');
|
|
8
8
|
const { generateReport } = require('../lib/report');
|
|
9
|
+
const { runAudit } = require('../lib/audit');
|
|
10
|
+
const { runCheck } = require('../lib/check');
|
|
9
11
|
const chalk = require('chalk');
|
|
10
12
|
|
|
11
13
|
program
|
|
@@ -58,6 +60,24 @@ program
|
|
|
58
60
|
await generateReport(taskIds, targetPath);
|
|
59
61
|
});
|
|
60
62
|
|
|
63
|
+
program
|
|
64
|
+
.command('audit')
|
|
65
|
+
.description('List files with unstaged changes (not yet git add)')
|
|
66
|
+
.option('-p, --path <path>', 'Target directory (default: current directory)')
|
|
67
|
+
.action(async (options) => {
|
|
68
|
+
const targetPath = options.path || process.cwd();
|
|
69
|
+
await runAudit(targetPath);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
program
|
|
73
|
+
.command('check')
|
|
74
|
+
.description('Run lint fix when available, then build')
|
|
75
|
+
.option('-p, --path <path>', 'Target directory (default: current directory)')
|
|
76
|
+
.action(async (options) => {
|
|
77
|
+
const targetPath = options.path || process.cwd();
|
|
78
|
+
await runCheck(targetPath);
|
|
79
|
+
});
|
|
80
|
+
|
|
61
81
|
program
|
|
62
82
|
.command('info')
|
|
63
83
|
.description('Show information about RBIN Task Flow')
|
|
@@ -74,6 +94,8 @@ program
|
|
|
74
94
|
console.log(chalk.cyan(' rbin-task-flow version-check') + ' - Check for model updates');
|
|
75
95
|
console.log(chalk.cyan(' rbin-task-flow estimate <ids>') + ' - Estimate time (e.g., "1" or "1,2" or "all")');
|
|
76
96
|
console.log(chalk.cyan(' rbin-task-flow report <ids>') + ' - Generate report (e.g., "1" or "1,2" or "all")');
|
|
97
|
+
console.log(chalk.cyan(' rbin-task-flow check') + ' - Run lint fix and build when available');
|
|
98
|
+
console.log(chalk.cyan(' rbin-task-flow audit') + ' - List unstaged files (not yet git add)');
|
|
77
99
|
console.log(chalk.cyan(' rbin-task-flow info') + ' - Show this information\n');
|
|
78
100
|
});
|
|
79
101
|
|
package/lib/audit.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
|
|
5
|
+
function getUnstagedFiles(targetPath) {
|
|
6
|
+
const cwd = path.resolve(targetPath);
|
|
7
|
+
try {
|
|
8
|
+
const out = execSync('git diff --name-only', { encoding: 'utf8', cwd });
|
|
9
|
+
return out
|
|
10
|
+
.trim()
|
|
11
|
+
.split('\n')
|
|
12
|
+
.filter(Boolean);
|
|
13
|
+
} catch (err) {
|
|
14
|
+
if (err.stderr && (err.stderr.includes('not a git repository') || err.message.includes('not a git'))) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
throw err;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function runAudit(targetPath = process.cwd()) {
|
|
22
|
+
const files = getUnstagedFiles(targetPath);
|
|
23
|
+
|
|
24
|
+
if (files === null) {
|
|
25
|
+
console.log(chalk.red('❌ Not a git repository. Run from a project root with git initialized.'));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (files.length === 0) {
|
|
30
|
+
console.log(chalk.yellow('⚠️ No unstaged changes. All modified files are staged (or working tree is clean).'));
|
|
31
|
+
console.log(chalk.gray(' Use "task-flow: audit" after editing files and before "git add".'));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
console.log(chalk.cyan('📋 Unstaged files (not yet added with git add):'));
|
|
36
|
+
console.log(chalk.cyan('─'.repeat(50)));
|
|
37
|
+
files.forEach((f) => console.log(chalk.white(' ' + f)));
|
|
38
|
+
console.log(chalk.cyan('─'.repeat(50)));
|
|
39
|
+
console.log(chalk.magenta(' Total:'), chalk.yellow(files.length), chalk.magenta('file(s)'));
|
|
40
|
+
console.log('');
|
|
41
|
+
console.log(chalk.gray(' Tip: run lint/test only on these paths, then "git add" when ready.'));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = { runAudit, getUnstagedFiles };
|
package/lib/check.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
|
|
6
|
+
function getPackageManager(targetPath) {
|
|
7
|
+
const cwd = path.resolve(targetPath);
|
|
8
|
+
|
|
9
|
+
if (fs.existsSync(path.join(cwd, 'pnpm-lock.yaml'))) {
|
|
10
|
+
return 'pnpm';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (fs.existsSync(path.join(cwd, 'yarn.lock'))) {
|
|
14
|
+
return 'yarn';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (fs.existsSync(path.join(cwd, 'bun.lockb')) || fs.existsSync(path.join(cwd, 'bun.lock'))) {
|
|
18
|
+
return 'bun';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return 'npm';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function readPackageJson(targetPath) {
|
|
25
|
+
const packageJsonPath = path.join(path.resolve(targetPath), 'package.json');
|
|
26
|
+
|
|
27
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function buildRunCommand(packageManager, scriptName, args = []) {
|
|
35
|
+
if (packageManager === 'yarn') {
|
|
36
|
+
return ['yarn', scriptName, ...args].join(' ');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return [packageManager, 'run', scriptName, ...(args.length > 0 ? ['--', ...args] : [])].join(' ');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function resolveLintScript(scripts = {}) {
|
|
43
|
+
if (scripts['lint:fix']) {
|
|
44
|
+
return { scriptName: 'lint:fix', label: 'lint:fix' };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (scripts['lint-fix']) {
|
|
48
|
+
return { scriptName: 'lint-fix', label: 'lint-fix' };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (scripts.lint) {
|
|
52
|
+
if (scripts.lint.includes('--fix')) {
|
|
53
|
+
return { scriptName: 'lint', label: 'lint' };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return { scriptName: 'lint', args: ['--fix'], label: 'lint --fix' };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function runScript(targetPath, packageManager, scriptConfig) {
|
|
63
|
+
const command = buildRunCommand(packageManager, scriptConfig.scriptName, scriptConfig.args);
|
|
64
|
+
execSync(command, {
|
|
65
|
+
cwd: path.resolve(targetPath),
|
|
66
|
+
stdio: 'inherit',
|
|
67
|
+
encoding: 'utf8'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function runCheck(targetPath = process.cwd()) {
|
|
72
|
+
const cwd = path.resolve(targetPath);
|
|
73
|
+
const packageJson = readPackageJson(cwd);
|
|
74
|
+
|
|
75
|
+
if (!packageJson) {
|
|
76
|
+
console.log(chalk.red('❌ package.json not found. Run this command from a project root.'));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const packageManager = getPackageManager(cwd);
|
|
81
|
+
const scripts = packageJson.scripts || {};
|
|
82
|
+
const lintScript = resolveLintScript(scripts);
|
|
83
|
+
const hasBuild = Boolean(scripts.build);
|
|
84
|
+
let ranSomething = false;
|
|
85
|
+
|
|
86
|
+
console.log(chalk.cyan('🔎 Running project checks'));
|
|
87
|
+
console.log(chalk.gray(` Package manager: ${packageManager}`));
|
|
88
|
+
|
|
89
|
+
if (lintScript) {
|
|
90
|
+
ranSomething = true;
|
|
91
|
+
console.log(chalk.cyan(`\n▶ Running ${lintScript.label}`));
|
|
92
|
+
runScript(cwd, packageManager, lintScript);
|
|
93
|
+
} else {
|
|
94
|
+
console.log(chalk.yellow('\n⚠️ No lint script found. Skipping lint step.'));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (hasBuild) {
|
|
98
|
+
ranSomething = true;
|
|
99
|
+
console.log(chalk.cyan('\n▶ Running build'));
|
|
100
|
+
runScript(cwd, packageManager, { scriptName: 'build' });
|
|
101
|
+
} else {
|
|
102
|
+
console.log(chalk.yellow('\n⚠️ No build script found. Skipping build step.'));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!ranSomething) {
|
|
106
|
+
console.log(chalk.yellow('\n⚠️ Nothing to run. Add a lint and/or build script to package.json.'));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
console.log(chalk.green('\n✅ Checks completed successfully.'));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = { runCheck };
|