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

Added npm task for each grunt task. Updated developing documentation. #488

Closed
wants to merge 5 commits into from

Conversation

ZachTRice
Copy link
Contributor

@ZachTRice ZachTRice commented Aug 28, 2017

Connects to #439
Added npm task for each grunt task.
Updated developing documentation.
Added .npmrc file to supress npm ERR! on fail
Converted eslint, stylelint, stylefmt, autoprefix grunt commands into pure npm run commands.

@ZachTRice
Copy link
Contributor Author

This PR is to get the ball rolling on converting the grunt scripts. Basically for each grunt script I created a npm script with the same name and attached the current grunt command to it. This way we can start using npm run [command_name] now (even though they still point to the grunt command) and start updating each one incrementally to the pure npm method, removing the grunt dependencies as we go.

- Added .npmrc file to silent npm ERR messages on fail.
- Added postcss-cli to run postcss plugins via npm.
- Converted stylelint, stylefmt, autoprefixer to use npm run
@ghost ghost assigned ZachTRice Aug 31, 2017
@ghost ghost added the under development label Aug 31, 2017
@@ -0,0 +1,3 @@
{
loglevel=silent
Copy link
Contributor

Choose a reason for hiding this comment

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

Sometimes npm errors can be useful. Possible loglevel values are "silent", "error", "warn", "notice", "http", "timing", "info", "verbose", "silly". I think we should leave the loglevel at warn or higher to avoid suppressing useful information about problems. A user can always run an npm script with the -s or --silent flags to hide errors, and if there's a particular script that we want to suppress warnings for, we could do something like "test":"npm run lint -s && npm run e2e -s".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were issues with using the silent flag which I can't remember now. .npmrc is the most consistent way to control logging. I will need to revisit this and see what we can do because when running linters, it was really hard to see what the issue was because of all the npm error messages.

Copy link
Contributor

Choose a reason for hiding this comment

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

Which version of npm are you using? Updating to node v8.2.1 and npm v5.4.2 makes the default error messages much shorter.

There's a discussion about this on the npm repo with a lot of potential workarounds: npm/npm#8821

The final solution was an update to npm which makes the log messages shorter as of npm v5.4.2: npm/npm@65b9943

We should add an npm key with 5.4.2 in the engines field in package.json, and then update version-check.js to also check the npm version.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here's an example after the update;
screen shot 2017-09-27 at 10 46 14 am

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using npm 3.8.10 as this is the default that ships with the node.js long term stable installer. Yep, I read through that discussion as well. Those messages look better in npm 5. But, I think we should stick with supporting what is included in the default nodejs lts install.

Copy link
Contributor

Choose a reason for hiding this comment

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

Worldview barely uses Node, since it's all client side code, so we shouldn't worry too much about Node updates breaking things anyway, since it would mostly affect developers and not users.

Copy link
Contributor Author

@ZachTRice ZachTRice Sep 27, 2017

Choose a reason for hiding this comment

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

I personally wouldn't mind upgrading to 5. I wanted to use it to link the semver of the options repo but that wasn't a very good reason to upgrade since I can link it to the tagged version with 3. I just worry about upgrading npm and making it harder for developers because of the fact that the default lts has 3 and most people will install that first and probably never upgrade.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keep in mind upgrading node and npm on Windows is not as straight forward as Mac. (Though it's not rocket science either).
See: https://stackoverflow.com/questions/18412129/how-do-i-update-node-and-npm-on-windows

I personally use nvm for windows: https://github.com/coreybutler/nvm-windows
But that's also not as straight forward as using nvm on Mac.

Copy link
Contributor

Choose a reason for hiding this comment

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

Our engines field and version-check.js are just recommendations, and not a hard requirement. I don't see any reason why our app isn't backwards compatible for developers who have an older version of Node installed. But, just in case, we use the version check to warn developers on older versions that they may have to update Node if they run into any problems. Since our Node dependencies are minimal, I doubt anyone would run into problems. But asking a developer to update Node if they do run into a problem doesn't seem like a big deal to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

The only real risk (and I'd argue that it's still very small) is that us even using a newer version of Node while developing (even without making explicit changes to the engines/version check) could end up with us writing code that depends on newer Node features without realizing it which then don't work for developers who have an older version of Node installed. The best way to make sure that we don't run into that is to make sure that the engines fields have the version numbers that we're actually using in development.

The engines fields and version checks are basically saying "Hey, these are the versions we're using, so if you have any problems, try using these too."

},
"devDependencies": {
"autoprefixer": "7.1.1",
"babel-polyfill": "6.16.0",
"bluebird": "3.4.6",
"buster": "0.7.12",
"chromedriver": "2.25.1",
"cssnano": "^4.0.0-rc.2",
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No where yet. It is intended to replace grunt-contrib-cssmin

@ZachTRice ZachTRice closed this Oct 30, 2017
@ghost ghost removed the under development label Oct 30, 2017
@ZachTRice ZachTRice deleted the grunt-to-npm branch November 15, 2017 17:53
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.

None yet

2 participants