gitlogg icon indicating copy to clipboard operation
gitlogg copied to clipboard

Enable easy installation via NPM

Open cspotcode opened this issue 7 years ago • 8 comments

It would be great if we could install gitlogg via npm.

$ npm install -g gitlogg
$ gitlogg ./myrepos/*/

So a wrote a PR for that. You can test the PR like so:

$ npm install -g @cspotcode/gitlogg

(I'll unpublish that scoped package if you decide to merge this PR)

...but ideally you could publish gitlogg to npm so it would be as simple as npm install gitlogg.

The interface has changed slightly. Instead of a hardcoded $yourpath variable, you now pass each repository as an argument. This means gitlogg ./myrepos/*/ will still look at every repository in a directory.

npm run prepublish precompiles the .js with babel. Since this might be annoying to remember during development, setting the GITLOGG_DEV environment variable will trigger the old behavior: babel will be invoked at runtime.

EDIT: Installing directly from github wasn't working so I published to npm @cspotcode/gitlogg

cspotcode avatar Nov 19 '16 18:11 cspotcode

Hi @cspotcode, this is very exciting! You've basically read my mind about distributing it to npm, but you've taken it a step further, well done!

I've tested this, but am not sure if I did it correctly. Here were my tries:

1st try

1. npm install -g @cspotcode/gitlogg

Saw it available from /Users/Wallace/.nvm/versions/node/v4.3.0/bin/gitlogg, so we're good.

2. Created an empty directory

mkdir testing
cd testing/

3. Copied a folder called repos into it. That folder already had a few repos within itself.

4. Ran gitlogg ./repos/*/ from within that directory, got this output:

gitlogg-1st-run

But again, maybe I'm having the wrong expectation, but I thought it was the idea since gitlogg was installed globally.

PS: I tried this a few times, the screenshot above was taken the first time, from within a different folder than testing.

2nd try

1. From within the same folder from previous try, I cloned your fork and checked out to the pull-request branch:

git clone git://github.com/cspotcode/gitlogg.git
cd gitlogg/
git checkout -b cspotcode-feature/npm-distribution master
git pull git://github.com/cspotcode/gitlogg.git feature/npm-distribution

2. npm install to get the dependencies 3. npm run prepublish to pre-compile the .js, got the following output

Wallaces-iMac:gitlogg Wallace$ npm run prepublish

> [email protected] prepublish /Users/Wallace/Sites/testing/gitlogg
> npm run build


> [email protected] build /Users/Wallace/Sites/testing/gitlogg
> babel --source-maps --out-file gitlogg/gitlogg-parse-json.compiled.js gitlogg/gitlogg-parse-json.js

Wallaces-iMac:gitlogg Wallace$

That did generate gitlogg-parse-json.compiled.js and gitlogg-parse-json.compiled.js.map, so all is fine.

4. Copied the folder repos into the root of the cloned gitlogg repo. 5. Ran gitlogg ./repos/*/ from within that directory, got this output (beside the js error that was rendered on the first screenshot) :

/Users/Wallace/.nvm/versions/node/v4.3.0/bin/gitlogg: line 10: /Users/Wallace/Sites/testing/gitlogg/gitlogg-generate-log.sh: No such file or directory

Realising I had to be within the gitlogg folder, I cd'ed to it:

6. cd gitlogg 7. gitlogg ./repos/*/, got the following output:

gitlogg-2nd-run

Oops, the script expected ./repos/*/ to be where the script runs from (that was not the case before). So I moved the folder repos to where the scripts are, gitlogg

8. Moved repos to the gitlogg folder 9. gitlogg ./repos/*/, got the following output:

gitlogg-3rd-run

The gitlogg.json file was generated, but empty.

I guess the js error I'm getting is probably related to babel and the GITLOGG_DEV environment variable, but I wanted to stick to default values and see how it went.

Maybe I'm missing something. Could there be a missing step somewhere?

I understand you wanted the path not to be hardcoded and I'm totally fine with that, but I do miss the errors when the path isn't specified and when the folder is empty. You think you could bring them back?

dreamyguy avatar Nov 20 '16 16:11 dreamyguy

I've pushed some changes I have meant to do for a long time, as I felt the former initial setting up was too complex and somewhat confusing. I've also realised I'd suggested in the README that one could just move the sub-folder gitlogg around and still run the scripts without problems, which is not true. The README is hopefully better now, and the setup much simpler.

The gitlogg subfolder was also renamed to scripts, to avoid confusion with the repo's root folder, which had the same name.

I guess we can continue to debug from the feature-branch, and sort out the conflicts when we're ready to merge the PR. 🎱

dreamyguy avatar Nov 21 '16 00:11 dreamyguy

Sweet, sounds great. I'm travelling for Thanksgiving all of today (driving yay) but I'll take a look at this tomorrow.

On Nov 20, 2016 19:25, "Wallace Sidhrée" [email protected] wrote:

I've pushed some changes I have meant to do for a long time, as I felt the former initial setting up was too complex and somewhat confusing. I've also realised I'd suggested in the README that one could just move the sub-folder gitlogg around and still run the scripts without problems, which is not true. The README is hopefully better now, and the setup much simpler.

The gitlogg subfolder was also renamed to scripts, to avoid confusion with the repo's root folder, which has the same name.

I guess we can continue to debug from the feature-branch, and sort out the conflicts when we're ready to merge the PR. 🎱

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dreamyguy/gitlogg/pull/9#issuecomment-261818077, or mute the thread https://github.com/notifications/unsubscribe-auth/AAW-uHq-lTvg1TVdAqws0wUJ_vPUIfh4ks5rAOUKgaJpZM4K3Up8 .

cspotcode avatar Nov 21 '16 16:11 cspotcode

I made a bunch of updates and pushed a new version to @cspotcode/gitlogg. You can test it with:

$ npm install -g @cspotcode/gitlogg
$ gitlogg ./path/to/repo

EDIT: forgot to mention, it's rebased on top of your latest changes as well.

cspotcode avatar Dec 01 '16 09:12 cspotcode

Hi @cspotcode I'm really looking forward to reviewing this! 👍

It's the end of the year and the place I work at has all kind of deadlines to be met. Typical. I'll be at it asap, but that could mean a good while from now.

My priority will always be performance, but if the output is saner without compromising already existing features/fields, I'm all in.

At a glance your changes are pretty radical, and that's not a bad thing, but I might consider merging it to a new branch, until a time comes to consolidate it all together over a few compromises.

Cheers for your contrib so far, I'll be coming back to this as soon as I can. 🦄 ✨

dreamyguy avatar Dec 01 '16 22:12 dreamyguy

Hi again @cspotcode. I'm testing on a new machine with everything installed from scratch. Testing this was pretty much the first thing I did.

I got the exact same try errors I have already posted on the screenshots, but this time there was only this error besides that:

/Users/123/.nvm/versions/node/v6.9.1/bin/gitlogg: line 10: /Users/123/Sites/gitlogg-generate-log.sh: No such file or directory

...which points to this line.

dreamyguy avatar Dec 03 '16 19:12 dreamyguy

OK, I'll take a look tomorrow.

On Dec 3, 2016 14:31, "Wallace Sidhrée" [email protected] wrote:

Hi again @cspotcode https://github.com/cspotcode. I'm testing on a new machine with everything installed from scratch. Testing this was pretty much the first thing I did.

I got the exact same try errors I have already posted on the screenshots, but this time there was only this error besides that:

/Users/123/.nvm/versions/node/v6.9.1/bin/gitlogg: line 10: /Users/123/Sites/gitlogg-generate-log.sh: No such file or directory

...which points to this line https://github.com/dreamyguy/gitlogg/blob/a310d5b2599df5450aed8059d8cb085049326239/scripts/gitlogg.sh#L10 .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dreamyguy/gitlogg/pull/9#issuecomment-264660197, or mute the thread https://github.com/notifications/unsubscribe-auth/AAW-uPiNR80NjWtTpHEr27BWtbzoho6jks5rEcOZgaJpZM4K3Up8 .

cspotcode avatar Dec 03 '16 19:12 cspotcode

I fixed the errors you were seeing. I think it was caused by double- versus single-quotes in a bash script; I guess we're running different versions of bash?

You can install a fixed package with npm install -g @cspotcode/[email protected].

I've also been making some bigger changes which I'll submit in a separate PR and am publishing to @cspotode/gitlogg with newer version numbers.

cspotcode avatar Dec 12 '16 01:12 cspotcode