Line of code counter for Git repositories
222
To run as a local webserver
docker run -d --name klock-server --rm -v klock:/root/.config/configstore -p 8080:8080 alexivkin/klock --webserver
To run as a command line tool
docker run --name klock -it --rm -v klock:/root/.config/configstore alexivkin/klock
npm installnode server.js for the webserver or nodejs cli.js as a CLIFirst, you need to register klock as the OAuth app in your GHE server. Go to https://yourgheserver/settings/applications/new, name the app as klock, define the home page as http://clochost:port, point the callback to http://clochost:port/gh/callback. Click OK and take note of the client ID and the secret. Set GH_OAUTH2_ID and GH_OAUTH2_SECRET environment variables to these values and run klock, like this:
GH_OAUTH2_ID=<shorternumber> GH_OAUTH2_SECRET=<longernumberhere> nodejs cli.js --webserver --local_url https://yourgheserver --gh
If you are using docker specify GH_OAUTH2_ID and GH_OAUTH2_SECRET using docker's -e option and expose the port 8080 with -p [localport]:8080 option
No setup is needed. The app will use username/password for authentication. Simply run as
nodejs cli.js --webserver --local_url http://yourbitbucketserver:7990 --bb
or
docker run -it --rm --name klock -v klock:/root/.config/configstore -p 8080:8080 alexivkin/klock --webserver --local_url http://yourbitbucketserver:7990 --bb
nodejs cli.js --zip file.zip
or
docker run -it --rm --name klock -v klock:/root/.config/configstore -v /local-folder-with-zip:/remote-folder alexivkin/klock --zip /remote-folder/file.zip
You can convert the resulting JSON into a CSV by using a jq command like this:
jq -r '{key:"repo",value:{lang:"language",total:"line count",ext:{".xml":"xml loc"}}}, to_entries[] |[.key, .value.lang, .value.total, .value.ext[".xml"] ] | @csv' klock.json > klock.csv
The total line count includes XML lines, which are also listed in the separate column so you can subtract them manually.
To run klock with all the logging enabled set DEBUG environment variable to * (star)
DEBUG=* node cli.js --webserver --local_url=http://....
If you see errors about self-signed or expired SSL certificate set the following environment variable:
NODE_TLS_REJECT_UNAUTHORIZED='0'
If OAuth authentication results in the 404 error then the provided OAuth client ID does not match the client ID configured on GitHub. This is likely due using GHE and GitHub.com with the same instance of klock. Make sure to set the correct GH_OAUTH2_ID and GH_OAUTH2_SECRET
Content type
Image
Digest
Size
76.1 MB
Last updated
about 6 years ago
docker pull alexivkin/klock