Skip to content

Build: Migrate to grunt 0.4. #867

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

Merged
merged 3 commits into from
Mar 12, 2013
Merged

Build: Migrate to grunt 0.4. #867

merged 3 commits into from
Mar 12, 2013

Conversation

jzaefferer
Copy link
Member

Rename to Gruntfile, upgrade to newer grunt-css and grunt-html, update custom tasks. Drop qunit-junit plugin, not worth the trouble. Update release script to run grunt-prepare after npm-install.

tree diff between old and new dist:

1c1
< dist

---
> dist-0-3/
22d21
< │   ├── Gruntfile.js
270a270
> │   ├── grunt.js

File diff (diff -r -w -q dist dist-0-3/): https://gist.github.com/fb016517fa530ca75213

The banner creation changed: Whitespace is now more consistent, but slightly different. The "Includes: jquery.ui.[component]" line from non-concat files is gone.

Minifiers changed: grunt-contrib-uglify uses uglify2, grunt-css uses clean-css (instead of squish), so all minified files are different as well.

I've dropped the qunit-junit plugin instead of replacing it with the 0.4 compatible grunt-qunit-junit since that doesn't really work yet and the junit reports have provided no value to us while we were using

I'm done here, but would like someone to review and test before a merge to master.

@jzaefferer
Copy link
Member Author

Btw. to test just install grunt-cli globally, then you can npm install when switching branches and get the right local grunt version.

jshintrc: ".jshintrc"
},
files: {
src: [ "grunt.js", "build/**/*.js" ]
Copy link
Member

Choose a reason for hiding this comment

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

Gruntfile.js

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@mikesherov
Copy link
Member

One other note, while you're in build/release.js, you might as well change path.existsSync to fs to get rid of that node warning when you run grunt md5.

return "<strip_all_banners:" + file + ">";
});
}

function stripDirectory( file ) {
// TODO: we're receiving the directive, so we need to strip the trailing >
Copy link
Member

Choose a reason for hiding this comment

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

Is this still needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, removed.

@mikesherov
Copy link
Member

Thanks for doing this @jzaefferer ! Also, there was 1 thing that @Krinkle had to modify in Jenkins after we pushed core's upgrade to 0.4. I forgot what it was, but obviously coordinate that with him.

@mikesherov
Copy link
Member

Last thing to note was, when you add grunt-cli to package.json, you now have a viable npm test command to run, we should consider adding that like we did in core's package.json.

@Krinkle
Copy link
Member

Krinkle commented Dec 24, 2012

What I changed in Jenkins is to use ./node_modules/.bin/grunt <cmd> in the Shell Exec build steps of the Jenkins job(s). Since otherwise it will use the global grunt, which is (and should stay for now at) grunt 0.3.x. We want to use the local version anyway for the reason @mikesherov mentioned.

@Krinkle
Copy link
Member

Krinkle commented Dec 24, 2012

Actually:

[..] executables will be added to the PATH for executing the scripts.
[..] exported into the node_modules/.bin directory on npm install.

Path - scripts - NPM Doc

Testing with scripts.install = "echo $PATH;" I see that the following is added to the PATH for npm scripts:

:/usr/local/bin
:/usr/local/lib/node_modules/npm/bin/node-gyp-bin
:/path/to/your-project/node_modules/.bin
:$PATH

So inside the scripts.test property we don't need to prefix ./node_modules/.bin, unless a global version may exist that can conflict (since that has preference apparently).

@scottgonzalez
Copy link
Member

What I changed in Jenkins is to use ./node_modules/.bin/grunt in the Shell Exec build steps of the Jenkins job(s). Since otherwise it will use the global grunt, which is (and should stay for now at) grunt 0.3.x. We want to use the local version anyway for the reason @mikesherov mentioned.

Why is that the case? Why do we not want grunt-cli in there globally right now? I really don't think we should be putting grunt-cli in our dependencies.

@scottgonzalez
Copy link
Member

One thing I've been waiting for is the name change from lint -> jshint. Now that we've got it, I'd like to add a new lint task that lints CSS, HTML, JS.

@scottgonzalez
Copy link
Member

I'll try to test this out this week. Still knee-deep in site work right now.

@jzaefferer
Copy link
Member Author

Regarding the lint task: Let's make that the default? Or just add it as an extra task? Order should probably be js, css, html.

@scottgonzalez
Copy link
Member

I'm fine with making it the default (I'd still like a named task for it though), unless someone strongly objects to removing tests from the default task.

@mikesherov
Copy link
Member

I like running the tests in the default task personally. But I'd be just as fine removing it.

@mikesherov
Copy link
Member

Can we land this and then make the minor improvements later? I'm anxious to see this working.

@scottgonzalez
Copy link
Member

@mikesherov I don't want to land this until I've had time to do a dry run of the release process. That should happen early next week (I'm currently knee-deep in site work).

@mikesherov
Copy link
Member

no problem. I've got an itchy trigger finger.

@jzaefferer
Copy link
Member Author

Just tested and updated this with rc6 and a rebase against master, no changes required for the new rc, just one merge conflict to resolve (in the generate_themes task).

@@ -18,11 +18,11 @@ var

uiFiles = coreFiles.map(function( file ) {
return "ui/" + file;
}).concat( grunt.file.expandFiles( "ui/*.js" ).filter(function( file ) {
}).concat( expandFiles( "ui/*.js" ).filter(function( file ) {
Copy link
Member

Choose a reason for hiding this comment

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

What's with this? Does grunt.file.expandFiles no longer exist? What does it not (or no longer) do that grunt.file.expandMapping (called from expandFiles) does do?

Copy link
Member

Choose a reason for hiding this comment

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

expandFiles is gone and expandMappings returns a map of src -> dest, not an array.

Copy link
Member

Choose a reason for hiding this comment

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

Crap, you're right. It was removed...

@jzaefferer
Copy link
Member Author

I've updated to 0.4 final and rebase against master, its working again but also has too much cruft just to migrate to 0.4. I've file an issue against, hopefully we get some help from there: gruntjs/grunt#700

I also want to look into replacing our custom zip task with grunt-contrib-compress, same for grunt-contrib-clean and test the update for grunt-compare-size. Not sure if we should include those here and combine the testing effort, or land this PR asap and do the other updates separately.

@mikesherov
Copy link
Member

I'm all for land ASAP.

On Sat, Mar 2, 2013 at 7:45 AM, Jörn Zaefferer notifications@github.comwrote:

I've updated to 0.4 final and rebase against master, its working again but
also has too much cruft just to migrate to 0.4. I've file an issue against,
hopefully we get some help from there: gruntjs/grunt#700gruntjs/grunt#700

I also want to look into replacing our custom zip task with
grunt-contrib-compresshttps://github.com/gruntjs/grunt-contrib-compress/,
same for grunt-contrib-cleanhttps://github.com/gruntjs/grunt-contrib-cleanand test the update for
grunt-compare-sizehttps://github.com/rwaldron/grunt-compare-size/pull/16#issuecomment-14322746.
Not sure if we should include those here and combine the testing effort, or
land this PR asap and do the other updates separately.


Reply to this email directly or view it on GitHubhttps://github.com//pull/867#issuecomment-14327666
.

Mike Sherov
Lead Developer
SNAP Interactive, Inc.
Ticker: STVI.OB

@jzaefferer
Copy link
Member Author

@scottgonzalez are you okay with landing this before 1.10.2? I just did another round of testing and it looks good.

@@ -5,6 +5,19 @@ module.exports = function( grunt ) {
var path = require( "path" ),
fs = require( "fs" );

function expandFiles( files ) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this expandFiles() different than the other? Why don't we just expose it instead of redefining it?

Copy link
Member Author

Choose a reason for hiding this comment

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

The other one is used directly, and only points at files. This one is used via tasks and gets folder wildcards as inputs. Folders have to be filtered out.

I'm not sure what you mean with "expose it instead of redefining it".

See also gruntjs/grunt#700

@scottgonzalez
Copy link
Member

If you've tested the release script, then we can land it.

@jzaefferer
Copy link
Member Author

The release script still runs "grunt prepare" inside the DB module, but we don't need that anymore, right? I mean, grunt release_cdn works fine as long as you install DB first, but there's no need to run its prepare task. That's the only issue I noticed when running the release script.

@scottgonzalez
Copy link
Member

Ok, so let's remove the invocation for the prepare task.

Let's just ignore the expandFiles() until later.

…unt-css and grunt-html, update custom tasks. Drop qunit-junit plugin, not worth the trouble. Update release script to run grunt-prepare after npm-install.
@jzaefferer
Copy link
Member Author

Probably our fastest build ever, mostly due to the theme generation change. 25 seconds to run the full release_cdn task.

@jzaefferer jzaefferer merged commit ae3af7f into master Mar 12, 2013
@jzaefferer jzaefferer deleted the grunt-0-4 branch March 12, 2013 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants