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

Add fancy install script, closes #217 #218

Closed
wants to merge 1 commit into from

Conversation

arichiardi
Copy link

Here it is, can of course be improved on fanciness 🚬

@arichiardi
Copy link
Author

Still not working, but close 😉

@arichiardi
Copy link
Author

Works now! Let me know or push a commit if there are issues ok?

@scottchiefbaker
Copy link
Contributor

I like the idea of this, but I think it needs a couple of tweaks

  1. Some sort of error if the user doesn't have git installed
  2. Error out if ~/bin/ isn't in the path
    1. Offer an option to install to another directory in path?

Overall I'm impressed though. Good work!

@arichiardi
Copy link
Author

arichiardi commented Mar 1, 2017

Oh oh well, I guess I gave for granted that they would have git 😀

What the error text could be?

About the bin folder, this is actually an argument probably...

@OJFord
Copy link
Member

OJFord commented Mar 1, 2017

Some sort of error if the user doesn't have git installed

Is that really necessary?

The install process doesn't depend on git, #193 is adding Mercurial support, and we're even discussing in #220 how to use dsf with non-VCS diffs.

Even if I am using dsf with git, if I have my own install script which does ... && install_dsf && install_git && ..., it's annoying if I have to change that after discovering it errors because dsf needs git at runtime (though it actually doesn't, per above) if it doesn't at install time.

@arichiardi
Copy link
Author

Ah good to know,.

Also, where do folks usually install bin? I personally use $HOME/bin, but usr/local/bin is probably the classic Linux default.

@OJFord
Copy link
Member

OJFord commented Mar 1, 2017

Also, where do folks usually install bin? I personally use $HOME/bin, but usr/local/bin is probably the classic Linux default.

Personally I think /usr/local/bin is better, pretty likely to already be on $PATH whereas $HOME/bin will be only for you, and others that deliberately use it. I do too, but only for small 'n-off' (for n slightly larger than 1) stuff that I've written for myself - so I'd be slightly annoyed if an install script put something third-party there. But that might just be me.

I certainly don't think ~/bin not already on $PATH should be an error. That will hit the vast majority of users, and they'd be surprised.

It would also mean this script couldn't be used in the Homebrew formula - which should IMO be a goal, (not that what I think matters - up to @stevemao 🙂) at the moment it adds a node/npm dependency, which is not necessary but presumably done for ease of maintanence, which this script can hopefully solve. It'd be nice not to have brew install all of node just for a relatively tiny bash/perl script.

@arichiardi
Copy link
Author

@OJFord so can you confirm that brew installs in /usr/local/bin? Or shall I pass a parameter there? Not very familiar with brew...

@scottchiefbaker
Copy link
Contributor

I forgot about mercurial/vanilla diff support. You can ignore my comment a missing git error message.

My vote for installation location is ~/bin/ if it's available/created. By default a lot of installs won't have this, A fall back to /usr/local/bin/, would be my second choice, but that will require root to write to.

@scottchiefbaker
Copy link
Contributor

Think the installer should attempt to put the files in ~/bin/ IF it's already in the path. If it's not in the path attempt to put the files in /usr/local/bin but error out if the user is not root. That should cover both our install scenarios.

Perhaps this is a separate issue, but I HATE the default colors. After install people will expect the output to be the same as the screenshot in the README. Perhaps we set the colors for the user? Or offer an option to use the d-s-f "suggested colors"?

@arichiardi
Copy link
Author

arichiardi commented Mar 1, 2017 via email

@OJFord
Copy link
Member

OJFord commented Mar 1, 2017

can you confirm that brew installs in /usr/local/bin

I can.

Perhaps we set the colors for the user?

Please don't do this by default. Installing dsf shouldn't alter my non-dsf config options unless I explicitly opt in; colours are diff (git core) and diff-highlight options.

@scottchiefbaker
Copy link
Contributor

Please don't do this by default. Installing dsf shouldn't alter my non-dsf config options unless I explicitly opt in; colours are diff (git core) and diff-highlight options.

We should definitely make it an option... "Use default d-s-f colors (will update your gitconfig)?" or something like that.

@scottchiefbaker
Copy link
Contributor

@arichiardi where are we at on this? I'm ready to merge this if we can include an option to set the default colors.

[color]
	ui = always
[color "diff"]
	meta = yellow bold
	commit = green bold
	frag = magenta bold
	old = red bold
	new = green bold
	whitespace = red reverse
[color "diff-highlight"]
	oldNormal = red bold
	oldHighlight = "red bold 52"
	newNormal = "green bold"
        newHighlight = "green bold 22"

@arichiardi
Copy link
Author

@scottchiefbaker oh cool!
I have had a pretty busy open source month 😄 Feel free to add this in and a subsequent commit can add default colors.

@scottchiefbaker
Copy link
Contributor

@arichiardi we're really close to a 1.0.0 release of d-s-f and I really want this to be part of that. Will you have any time coming up that we can refresh this with a couple of tweaks and then I can land it?

@scottchiefbaker scottchiefbaker added this to the 1.0.0 milestone Mar 24, 2017
@arichiardi
Copy link
Author

arichiardi commented Mar 24, 2017 via email

@scottchiefbaker
Copy link
Contributor

master is stable right now, so you can make changes as you see fit. As the last part of the install script I'd like to offer to set the default colors for the user. There is a new option:

diif-so-fancy --colors

That will output the commands needed to set the default colors. Perhaps we can include that in some fashion.

@scottchiefbaker
Copy link
Contributor

scottchiefbaker commented Mar 24, 2017

As of now the only files that are needed are /diff-so-fancy and /third_party/diff-highlight/diff-highlight. Putting those in ~/bin should be sufficient.

The libexec directory is no longer needed.

@scottchiefbaker
Copy link
Contributor

Actually for simplicity you could put both diff-so-fancy and diff-highlight in ~/bin (or anywhere in the path) and they will work just fine.

No need for a /third_party directory at all.

@arichiardi
Copy link
Author

True, will do that

@arichiardi arichiardi force-pushed the install-script branch 2 times, most recently from 1659ae6 to e7f08d5 Compare March 27, 2017 01:00
@arichiardi
Copy link
Author

Done! 🎆 🎉 🎈

@scottchiefbaker
Copy link
Contributor

This was with a brand new vanilla user on Fedora 25:

test@basement(~)
:sh install.sh
Check if '/home/test/bin' is writable: KO
Check if '/home/test/bin' is in PATH: OK
Check if '/usr/local/bin' is writable: KO
Check if '/usr/local/bin' is in PATH: OK
The default install directories could not be used.

In the first case, it looks like ~/bin is in the path by default, but not created? In that case I think it's a good idea to create the directory and put the files there. This was the behavior of the previous, and I think it's fine if ~/bin is in the path.

Lastly I'd like the install script to offer to set the recommended colors. diff-so-fancy --colors will output the commands for the recommended colors.

@scottchiefbaker
Copy link
Contributor

Moving forward, I think this will be the recommended way to install d-s-f. Rather than cloning the whole repo, or using sytem repos. This will always ensure that the user gets the latest version via the master branch.

@arichiardi
Copy link
Author

Yes I removed the creation part, assuming that if it is in the path, then it is writable/exists. But of course this assumption was wrong as it was shown above. I can bring it back to life.

@scottchiefbaker
Copy link
Contributor

Yes please bring that logic back to life, if the directory is in the path and writable.

@arichiardi
Copy link
Author

No well, if the directory is writable it means that it exists already...so only if it is in the path. Will do that.

@scottchiefbaker
Copy link
Contributor

scottchiefbaker commented Apr 3, 2017

Question... Do we want to install to ~/bin/ by default... or require the use to specify?

bash install.sh /path/to/install/to/

Or both... if you call install.sh without a path it tries ~/bin and errors if it can't?

@arichiardi
Copy link
Author

Yeah that is a UX question, I am fine with the current defaults, but I am going to wait for more answers to this one

@scottchiefbaker
Copy link
Contributor

@paulirish @stevemao @OJFord

Feedback on this?

install.sh Outdated
dsf_do_install() {

if ! dsf_has dsf_download; then
echo >&2 "You need curl or wget to install nvm";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/nvm/diff-so-fancy

@paulirish
Copy link
Member

I really love the ~/bin/ convention and suggest keeping that. If someone doesn't want an easy install script, then they should be fine with our Manual Install directions.

It seems reasonable for this script to doublecheck that ~/bin is in your PATH though. Adding it to the PATH should definitely stay the user's job. Hate when scripts toss stuff into my .bash_profile. :)

@arichiardi
Copy link
Author

@paulirish What about the creation of the folders if already in PATH? I usually don't like when scripts are messing with my stuff as well, but I assume that if you have something in PATH you actually want/wanted to have the folder in place and therefore I create it (maybe again if it had been removed).

On the other end if a user delete the folder but forgot to update PATH, creating it will maybe make her upset 😄

@paulirish
Copy link
Member

oh i see you already do the PATH check. :) all good.

i think the way you currently handle it is best (is it writeable? is it in path? great, lets go)

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me.

can you also add something to the readme in this PR?
gives us an opportunity to bikeshed how it shows up there amongst the other options. :)

@scottchiefbaker
Copy link
Contributor

@paulirish I'd like to completely revamp the README once we release 1.0.

It's a jumbled mess, with a ton of options.

@paulirish
Copy link
Member

@scottchiefbaker oh word. yeah that sounds excellent! though i'd advocate for the revamp before shipping 1.0, assuming the release brings us some new attention. :)

@arichiardi
Copy link
Author

arichiardi commented Apr 3, 2017

Ups pushed the wrong version wait a sec

EDIT: ok worked on the other laptop on this, give me some time to get back to work and re-push the right version

@arichiardi
Copy link
Author

Ok pushed the right version, still uncertain about reintroducing mkdir or not. Seeking advice.

@arichiardi
Copy link
Author

What is the status on this? Is there anything I need to add/remove so that we can merge it? Good job with the release!

@scottchiefbaker
Copy link
Contributor

I'm not sure where to go with this, I'm open to suggestions. With the release of 1.1.0 the installation is much simpler (one script). I think there is still a place for an install script that downloads the latest version and puts it in your $PATH appropriately. What do you think?

@OJFord
Copy link
Member

OJFord commented Aug 2, 2017

an install script that downloads the latest version and puts it in your $PATH appropriately. What do you think?

Sounds like a package manager?

@arichiardi
Copy link
Author

Oh well if there is one script already for that, and easy to call, then there is no need for an additional script.

@scottchiefbaker
Copy link
Contributor

Now that things are really simple, I don't think we need a full blown install script. Maybe we just need to expand the install docs to cover some other use cases? I'm going to close this for now. If there are strong objections let me know and I'll re-open it.

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

Successfully merging this pull request may close these issues.

5 participants