Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable easy installation via NPM #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

cspotcode
Copy link

@cspotcode cspotcode commented Nov 19, 2016

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

@dreamyguy
Copy link
Owner

dreamyguy commented Nov 20, 2016

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

> gitlogg@0.1.6 prepublish /Users/Wallace/Sites/testing/gitlogg
> npm run build


> gitlogg@0.1.6 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
Copy link
Owner

dreamyguy commented Nov 21, 2016

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. 🎱

@cspotcode
Copy link
Author

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" notifications@github.com 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
#9 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAW-uHq-lTvg1TVdAqws0wUJ_vPUIfh4ks5rAOUKgaJpZM4K3Up8
.

`npm install -g gitlogg` will put it on your path
Script is now agnostic to the pwd in which it's invoked
`.js` is pre-transpiled so babel isn't required at runtime
- set environment variable GITLOGG_DEV to enable runtime transpilation and avoid the build step
Instead of a hardcoded `yourpath` variable, each positional argument to `gitlogg` is a repository path.
- You can easily `gitlogg ./myrepos/*/` to process all repositories in a directory
`.js` reads and writes from file descriptors 3 and 4; these are managed by bash script
`--pretty=tformat` string is generated automatically from array of `git log` fields.
Each field is separated by a null character, which as far as I know can't appear naturally in any of those fields.
Babel now transpiles from .es to .js, which is easier than transpiling to .compiled.js now that there are multiple .es scripts
@cspotcode
Copy link
Author

cspotcode commented Dec 1, 2016

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.

@dreamyguy
Copy link
Owner

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
Copy link
Owner

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.

@cspotcode
Copy link
Author

cspotcode commented Dec 3, 2016 via email

@cspotcode
Copy link
Author

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/gitlogg@0.1.11.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants