This CLI tool is intended to make interacting with Codiga as smooth as possible.
Ensure you have Node.js installed first. You can do that by running the following in your terminal.
If you don't have it installed, go to download Node.js now.
node -vNow you can install our CLI tool with either of the following.
# if you want to add it to your package.json
npm i --save-dev @codiga/cli
# if you want to install it globally
npm i -g @codiga/cliRun the following command to see what's available directly in your terminal or keep reading for more.
codiga --helpUse the command below to set your Codiga API token. This token will be needed to run certain operations. You can create a Codiga API token on our app.
codiga token-addUse the command below to check if you have a valid Codiga API token set. You can create a new Codiga API token on our app.
codiga token-checkUse the command below to delete a Codiga API token from your system. You can manage your Codiga API tokens on our app.
codiga token-deleteUse the command below to detect any violations between your two commits.
As the command name suggests, this works best in a pre-push git hook. Everytime a git push command is ran, that developer will know that their code doesn't have any violations and if they do, they will need to push new commits to rectify those violations before pushing again.
codiga git-push-hook --remote-sha 1234567 --local-sha 7654321To utilize the git pre-push hook automatically, you'll need to follow "Getting Started" above and then copy the following into a .git/hooks/pre-push file and then run chmod a+x .git/hooks/pre-push to make it executable.
#!/bin/sh
while read local_ref local_sha remote_ref remote_sha
do
codiga git-push-hook --remote-sha $remote_sha --local-sha $local_sha
done
exit 0If you're already using a tool like husky to handle git hooks the following would go into a .husky/pre-push file and then run chmod +x .husky/pre-push to make it executable.
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
while read local_ref local_sha remote_ref remote_sha
do
codiga git-push-hook --remote-sha $remote_sha --local-sha $local_sha
done
exit 0MIT