-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
npm test currently doesn't work without globally installing grunt-cli #1053
Comments
I think this is very clearly spelled out in the installation docs. Bullet point 4 to be exact. |
More info about grunt and their architecture is available on their site. |
I should have mentioned the node community convention of Requiring the installation of global modules (modules that provide bins can be used without global installation, as described above) adds potential headache to getting an app running, as users may have permission issues regarding global module installation. There's no such thing as a 'global-only' module. It also means that if I ever distribute an app that uses ghost that I have to also force all of my users to install Closing this for now, just wanted to share how I've seen it done on NPM in the past. |
Having just tested this does enable running of tests from npm, although you still do require the sass and bourbon gems to be installed. With these other external dependencies I do agree grunt-cli should be development dependency, mainly because it makes building in isolation a little easier, and more likely to succeed if grunt totally breaks compatibility again... Just my 2 cents. |
@maxogden Specifying Have you tried to test that out? Your larger issue about keeping a code base free of dependencies is nice in theory, but we like the power that some of these third party tools (like Grunt, Sass and Bourbon) offer our developers more than keeping the Node "purist" happy. Thanks for the feedback though. @wolfeidau Grunt separated the cli tool from the grunt framework for precisely the reason you mention, the cli tool is now just a harness for running your local project version of Grunt. Again, just take a look at the Grunt docs. |
@jgable again, there's never a scenario where global installation is required. here's how to use
then add now run it currently throws an error because the |
That's interesting, I missed your thorough explanation in the first post of why it must be specified in the npm scripts for it to work. The I found this info in the [npm-scripts] docs:
It would appear that you can define and run arbitrary scripts using this method. But, If your argument is to make it a dependency just for npm test, that seems odd to me since we will definitely require it installed globally to get the site running which would cause the problems of conflicting versions anyway. |
weird, adding i'm on node the so-called node 'purist' way to do it would be to have a npm script in your package.json for each thing that your package needs to execute, thereby not depending on global CLI commands. a major benefit of npm is encapsulation and allowing multiple versions of modules to get installed in the same dependency tree, and any required global dependencies open up the possibility of an app breaking at runtime because it got the wrong version of a dependency. in the case of grunt it isn't so bad, as |
Ok, I got TIL all about npm scripts and local module scope. |
@jgable thanks for taking point on this - I was soaking it all up.
If we can achieve this - I think that would be awesome. I think right now we're missing out on a way to do a git submodule init & update? We'd also have to get smart in the grunt tasks about environments - running the right build script for the right environment. However, I think this is definitely the ideal to strive for, so I'm gonna reopen it. |
Here's what I think is going to be involved in this:
|
As @maxogden pointed out the @shama created an issue gruntjs/grunt#943 regarding this. The goal is to make it possible for |
issue #1053 - not the greatest module, but perhaps one to re-create ourselves in future
issue TryGhost#1053 - not the greatest module, but perhaps one to re-create ourselves in future
FIY I've ran into this as well and raised issue in grunt-cli. |
An update: installing |
I prefer running any tools like this from the local project hierarchy.
|
Blah.. this isn't quite right on Windoze...
Weirdly, I'm also not sure that |
Try updating to |
fixes TryGhost#1053 - npm install doesn't need a path to grunt, and fails on Windows if it has one - submodule update is handled by grunt (albeit badly... but let's fix that!)
I'm not convinced we've got this working properly for everyone or that the documentation / contribution guidelines are correct given #2191
|
It works for me on OSX 10.9.1 and node.js v0.10.22, ruby-2.0.0-p247. I did a fresh I then removed my globally installed grunt-cli with
The message: Happy to send a PR for any of the above if that is easier. Thanks! |
Another consideration, if Ghost is published to npm; the I don't know what Ghost's plans are for publishing to npm but a proactive solution is to move the install script to another hook, such as: "scripts": {
"build": "bundle install && grunt init"
} and ran with |
In short, I think we are trying to handle a few different use cases for Ghost, and potentially getting a bit confused as a result. Case 1) Installing from npm, which runs In the first case, the build is not necessary, as the npm package will contain built files the same as if you had downloaded a zip from Ghost.org or the GitHub releases page. In the second case, the build is necessary, the same occurs if you run Ghost through Travis. Our instructions, pretty much everywhere, tell people who are in case 1 - that is they have a pre-built ghost, to run I think the correct solution is to leave
As well as updating the Gruntfile to filter the grunt-cli task as mentioned in @shama's first comment:
|
👍 |
As you noted @ErisDS there is no need to run any npm script in this scenario as the built scripts will be included in the npm package. Adding
Small nit, but I'd argue we should move development specific commands back to the |
expected behavior of npm packages fixes TryGhost#1053 - updates travis config to be more in line with current dev steps - fix `grunt-cli` warning from appearing when running grunt
refs #18752, TryGhost/Product#3897, TryGhost/Product#4112, TryGhost/Product#4104, #18866, #18753, TryGhost/Product#4116, #18888, #18844 - 🐛 Fixed browser focus on editor when clicking card ([Koenig/#1051](TryGhost/Koenig#1051)) - 🐛 Fixed signup card styles with image background ([Koenig/#1052](TryGhost/Koenig#1052)) - 🐛 Fixed slash menu having fixed position when scrolling ([Koenig/#1054](TryGhost/Koenig#1054)) - 🐛 Fixed signup card text color with transparent background ([Koenig/#1053](TryGhost/Koenig#1053)) - 🐛 Fixed text formats being lost when copy/pasting from Google Docs ([Koenig/#1055](TryGhost/Koenig#1055)) - 🐛 Fixed pasting link behaviour in single line nested editors ([Koenig/#1056](TryGhost/Koenig#1056)) - 🐛 Fixed backspace behaviour at start of aside/quote ([Koenig/#1057](TryGhost/Koenig#1057)) - 🐛 Fixed text having unexpected formats when rendering ([Koenig/#1058](TryGhost/Koenig#1058)) - 🐛 Fixed placeholder descenders being cut off in nested editor ([Koenig/#1059](TryGhost/Koenig#1059)) - 🐛 Fixed HTML->Lexical conversion not handling paragraphs inside blockquotes ([Koenig/#1061](TryGhost/Koenig#1061))
refs #18752, TryGhost/Product#3897, TryGhost/Product#4112, TryGhost/Product#4104, #18866, #18753, TryGhost/Product#4116, #18888, #18844 - 🐛 Fixed browser focus on editor when clicking card ([Koenig/#1051](TryGhost/Koenig#1051)) - 🐛 Fixed signup card styles with image background ([Koenig/#1052](TryGhost/Koenig#1052)) - 🐛 Fixed slash menu having fixed position when scrolling ([Koenig/#1054](TryGhost/Koenig#1054)) - 🐛 Fixed signup card text color with transparent background ([Koenig/#1053](TryGhost/Koenig#1053)) - 🐛 Fixed text formats being lost when copy/pasting from Google Docs ([Koenig/#1055](TryGhost/Koenig#1055)) - 🐛 Fixed pasting link behaviour in single line nested editors ([Koenig/#1056](TryGhost/Koenig#1056)) - 🐛 Fixed backspace behaviour at start of aside/quote ([Koenig/#1057](TryGhost/Koenig#1057)) - 🐛 Fixed text having unexpected formats when rendering ([Koenig/#1058](TryGhost/Koenig#1058)) - 🐛 Fixed placeholder descenders being cut off in nested editor ([Koenig/#1059](TryGhost/Koenig#1059)) - 🐛 Fixed HTML->Lexical conversion not handling paragraphs inside blockquotes ([Koenig/#1061](TryGhost/Koenig#1061))
npm test
currently doesn't work in a freshly cloned + npm installed repo becausegrunt-cli
isn't indevDependencies
commands in the
scripts
field of package.json e.g.{"scripts": {"start": "ghost"}}
will resolve to the local module scope instead of requiring global installation. This means that working versions of modules can get bundled with applications.for example, in the above example when
npm start
runs it will look for a module in the local availablerequire
scope that provides aghost
bin, and will use that. if it can't find a local module it will try the $PATH.if I had two applications on my computer that both depend on ghost, but one depends on ghost v1 and another on ghost v2 (for example), it would suck if I had to
npm install -g ghost@1.0.0
every time I went into the first project and thennpm install -g ghost@2.0.0
in the other one. using npm scripts solves this problem. (I hope my explanation makes sense)The text was updated successfully, but these errors were encountered: