nielsenramon / chalk

Chalk is a high quality, completely customizable, performant and 100% free Jekyll blog theme.
http://chalk.nielsenramon.com
MIT License
1.23k stars 442 forks source link

Created NPM scripts in package.json to replace current build commands (and added Drafts support). #139

Closed artis3n closed 6 years ago

artis3n commented 6 years ago

& Added Intellij system files to .gitignore

Changes

Rationale

Changes to the commands (like adding --drafts) can occur without the user having to change the command they run. They run npm run local and behind the scenes the maintainers can update that command's function as needed.

Instead of having to remember longer commands or file paths, just run npm run <the thing you want> and it Shall Be Done for you. This was more of a pet peeve of mine.

Testing

This is not platform-dependent and all commands have been tested to work successfully.

Concerns

NPM has some standard commands (publish is one of them). If you run npm publish on this repo, the command will fail and give an error message that will lead the user down a red herring. They won't know that the command they want is npm run publish. The fix would be to rename the commands to any keyword that is not in the list of scripts, but I really like the word publish for the action that is happening. It probably makes more sense to make it npm run deploy, though.

migueldemoura commented 6 years ago

At first I thought the commands were executed by npm itself in javascript or something cross-platform, but it seems like the only thing happening is you now have an alias for each command using npm. Can you elaborate a bit on the benefits? :)

It seems that this is what you wanted: https://github.com/migueldemoura/migueldemoura.com/blob/master/bin/console

artis3n commented 6 years ago

Yup, just aliases. Little nicer to run for users in my opinion. It's what I use on my blog and thought I'd push that upstream. If there's no interest, I can close this PR and push one that solely has the --drafts addition. That should definitely be merged in to allow rendering of draft articles locally.

migueldemoura commented 6 years ago

Yep, that is pretty cool. Since we already require npm anyway, this could indeed be simpler. You seem to have investigated this pretty throughly; do you know any way of replacing the shell scripts with something cross-platform (i.e., that works on windows without WSL)? That would be really great for windows users.

artis3n commented 6 years ago

I don't think we're going to find something easily cross-platform. I imagine a Powershell script is what you would want to use for Windows, though. I am not very familiar, but this seems like a good place to start: https://gist.github.com/noelmace/997a2e3d3ced0e1e6086066990036b16. I'd be happy to look into it more in a new issue, although I don't know how quickly I would be able to get into it.

You could get into a dev ops tool like Ansible that could make the install cross-platform, but even as simple as Ansible is it feels like too heavy-handed a solution for this. If you want to look into that I could write up an Ansible playbook pretty quickly.

nielsenramon commented 6 years ago

@arikalfus I like it! Can you also update the post with the setup instructions please?

artis3n commented 6 years ago

re: Ansible - that's a terrible idea forget I said that.

@nielsenramon What setup instructions are you talking about? I replace the old commands in the README with these new ones.

migueldemoura commented 6 years ago

@arikalfus, I think he's talking about this:

https://github.com/nielsenramon/chalk/blob/master/_posts/2017-12-23-introducing-chalk.md

artis3n commented 6 years ago

Ah, right! Updated

nielsenramon commented 6 years ago

@arikalfus Thanks a lot!