12 Commits

Author SHA1 Message Date
Dan Poltawski
2ce9109088 MDL-55048 grunt/npm: Update dependencies
* We bump our minimum node version up to >=4. Although this isn't yet
  necessarily *required* it was spurred on because grunt dropped support
  for very early node versions and so it's likely some devs will have to
  upgrade their npm.

  We do it now which gives us more flexibility for tools going forward
  (especially for things like new theme/testing). And node has matured
  the ecosystem (especially supporting properly semver) so should result
  in less edge cases.

* We make the minimum node version explicit in package.json. Though it
  doesn't help much for older versions of node because npm doesn't
  have the functionality to warn about it.. ;-)

* Left async dependency as it was, because it's only on an RC: 2.0.0-rc.6
2016-07-11 15:53:10 +01:00
Dan Poltawski
037de71996 MDL-54944 eslint: Add rules from Policy decision
Also bump eslint to v2.13.1 and make the version explicit in
package.json
2016-07-07 12:10:49 +01:00
Dan Poltawski
5f4d957c21 MDL-54889 jshint: stop using for everything but shifter
Now jshint has been replaced by eslint.
2016-06-30 09:14:57 +01:00
Dan Poltawski
30db70abdc MDL-52127 grunt: be aware of third party paths
1) Parse thirdpartylibs.xml and generate an array of third party
file paths to use in grunt tasks
2) In the lint tasks, we filter third party files from being linted
3) We add a new task to generate ignore files - currently for eslint,
but will be potentially useful for other things in the future
4) Remove .eslintignore from source control

Why have the ability to generate a .eslintignore file? For tooling
integration - by having the eslintignore file people can use other
eslint tools without having to just use grunt (e.g. editor
integrations).
2016-06-14 00:37:29 +01:00
Dan Poltawski
3adb62b727 MDL-52127 js: check amd files with eslint grunt task
I have spent quite a lot of time working through the current list of
eslint options and configuring them for Moodle style and I think this is
a very good basis to start us at (as well as taking some of out jshint
options out with https://www.npmjs.com/package/polyjuice ). Thanks to
Andrew Nicols, Mark Johnson and Frédéric Massart for some refinements.

With this configuration the grunt build will fail if errors are present
in the js (though you can of course tell jshint to ignore some errors,
as I have done in admin/tool/lp/amd/src/competency_rule_points.js and
defining the Y global in lib/amd/src/yui.js ).

The grunt task will not report warnings by default, but a new
--show-lint-warnings flag will help achieve that. Editor
integrations/stanadalone eslint tool will surely be a better way of
getting eslint errors rather than using the grunt task.
2016-06-11 10:14:35 +01:00
Dan Poltawski
1aa454eda4 MDL-49817 grunt: handle multiple watched files changed at once
Includes multiple changes to the shifter task to simplify and
support this:
* Use grunt.file for shifter yui 'module' detection rather than our own
  70 line function
* Use grunt.util.spawn rather than our own exec for shifter
* Improve behaviour on various yui subdirectories

We have to add the 'async' depndency to npm because we are running
multiple async operations in the single task. We use async.eachSeries to
run each shifter job sequentally (else the output would be unreadable
when running async).

We also run shifter in non-recursive mode on the module directory so its
not building everything (thanks to Ryan for pointing this out!)
2016-01-28 08:30:04 +00:00
Dan Poltawski
8efbb7b1a1 MDL-49817 grunt: add watch task
This allows files to be watched and automatically build when changed.

Thanks to David Monllaó for the initial basis for this patch.
2016-01-28 08:27:31 +00:00
Dan Poltawski
302a3c5f7d MDL-52250 npm: remove uglify-js dependency/bump grunt-contrib-uglify
A) Remove direct dependency on uglify-js:

This dependency was added in MDL-50277, but it isn't quite correct, the
way npm installs dependencies means that grunt-contrib-uglify *could* use
'our' version if its satisifed. But does not *always* and especially does
not if the grunt-contrib-uglify requirement is higher than ours.

Long story short, in many cases this means that this is used:
 node_modules/grunt-contrib-uglify/node_modules/uglify-js
But this is not:
  node_modules/uglify-js

In MDL-50277 we thought we were making the version sticky, but in
reality we were just fixing previous problems by updating
grunt-contrib-uglify to a version which fixed a bug:

 https://github.com/gruntjs/grunt-contrib-uglify/issues/313

It seems the better solution will come with using npm shrinkwrap to lock
down depdencies.

B) Bump grunt-contrib-uglify to 0.11.0

This moves us to uglify-js ~2.6.0 - which doens't change any output
files.
2015-12-04 15:07:47 +00:00
Dan Poltawski
e90eb13a6b MDL-52204 grunt: update to grunt-contrib-jshint v0.11.3
This version of grunt-contrib-jshint itself uses a better fixed
requirement on "~2.8.0" rather than "^2.8.0" which was giving variable
results with some people updating to 2.9-rc1.

See also https://github.com/gruntjs/grunt-contrib-jshint/pull/219
2015-12-04 11:43:30 +00:00
Dan Poltawski
a4a52e565e MDL-51582 grunt: add less complilation support
Previously we were using recess to build bootstrap base as it was what
was used by the original project. But recess is no longer maintained.

Now we use grunt for building js, it makes sense to use it for less too.

(If you really don't want to use grunt, you almost certainly can just
use lessc -x as it uses the same less.js on backend).
2015-12-04 10:36:45 +00:00
Andrew Nicols
4218673093 MDL-50277 Javascript: Hardcode nodejs dependencies
In order to produce a consistent build across the board, we must hardcode
several package versions. We must additionally specify compatible
versions for any sub-dependency that we have a requirement upon.

In this instance, the only sub-dependency which has an effect upon the
overall output is grunt-contrib-uglify's dependency upon uglify-js.

Since change in uglify-js may lead to changes in the generated output, we
must specify a fixed version of that dependency. That version must be
compatible with the dependency signature for grunt-contrib-uglify or the
dependency manager will just download a different version.

This issue also bumps the version of uglify-js to a version which changes
the output. This is the latest version at time of commit.
2015-05-20 09:41:17 +08:00
Damyon Wiese
adeb96d28f MDL-49046 javascript: Add support for AMD modules and jquery.
Grunt is the build tool.
2015-02-23 16:23:10 +08:00