Skip to content

Commit 98585fc

Browse files
Merge stuff
2 parents 5155e9d + 9739a5f commit 98585fc

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# codacy-cli-v2
2+
3+
This is a POC for what could a new CLI for us. The idea is to rely on the native tools and SARIF format instead of relying on docker.
4+
5+
## Download
6+
7+
### MacOS brew
8+
9+
```bash
10+
brew install codacy/codacy-cli-v2/codacy-cli-v2
11+
```
12+
13+
### Linux
14+
15+
For linux we rely on `codacy-cli.sh` script on the root, to download the CLI you can:
16+
17+
```bash
18+
bash <(curl -Ls https://raw.githubusercontent.com/codacy/codacy-cli-v2/main/codacy-cli.sh)
19+
```
20+
21+
You can either put the downloaded script on a specific file, or an alias that will download the script and look for changes:
22+
```bash
23+
alias codacy-cli-v2="bash <(curl -Ls https://raw.githubusercontent.com/codacy/codacy-cli-v2/main/codacy-cli.sh)"
24+
```
25+
26+
## Important concepts
27+
28+
### `.codacy/.codacy.yaml`
29+
30+
Our CLI relies on the `.codacy/.codacy.yaml` to install and run the specified `node` and `eslint` versions.
31+
32+
Meaning that on the root of the repository that you want to analyse, you should create a `.codacy/.codacy.yaml` such as:
33+
34+
```yaml
35+
runtimes:
36+
37+
tools:
38+
39+
```
40+
41+
### `codacy-cli-v2 install`
42+
43+
Before running, you need to do an install command, so it downloads the specified `node` and `eslint` versions.
44+
To install the tools specified on your `.codacy/.codacy.yaml` you should:
45+
46+
```bash
47+
codacy-cli-v2 install
48+
```
49+
50+
## Run
51+
52+
For now, we only support ESLint, to run and output the results to the terminal:
53+
54+
```bash
55+
codacy-cli-v2 analyze eslint
56+
```
57+
58+
Alternatively, you can store the results as SARIF to a file:
59+
60+
```bash
61+
codacy-cli-v2 analyze eslint -o eslint.sarif
62+
```
63+
64+
## Example repo
65+
66+
As an example, that as an action that relies on this CLI, you can check <https://github.com/troubleshoot-codacy/eslint-test-examples>

cmd/analyze.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ var analyzeCmd = &cobra.Command{
3535
nodeRuntime := config.Config.Runtimes()["node"]
3636
nodeBinary := nodeRuntime.Info()["node"]
3737

38+
log.Printf("Running %s...\n", args[0])
39+
if outputFile != "" {
40+
log.Printf("Output will be available at %s\n", outputFile)
41+
}
42+
3843
tools.RunEslint(workDirectory, eslintInstallationDirectory, nodeBinary, outputFile)
3944
},
4045
}

0 commit comments

Comments
 (0)