Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-40156

Add wrapper around JS tools and help with versioning

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.5
    • Fix Version/s: None
    • Component/s: JavaScript, Themes
    • Labels:
    • Testing Instructions:
      Hide

      Install grunt-cli:

      sudo npm install grunt-cli -g
      

      Now for moodle:

      npm install .
      

      And to test:

       
      # should run shifter --walk --recursive
      cd path/to/moodle
      grunt s
       
      # should educate you
      cd path/to/moodle
      grunt s --watch
       
      # should run shifter --recursive
      cd path/to/moodle/lib/yui/src
      grunt s
       
      # should run shifter --recursive --watch
      cd path/to/moodle/lib/yui/src
      grunt s --watch
       
      # should run shifter
      cd path/to/moodle/lib/yui/src/tooltip
      grunt s
       
      # should run shifter --watch
      cd path/to/moodle/lib/yui/src/tooltip
      grunt s --watch
      

      No changes should be seen in the build files.

      We will also need to add npm_modules to the .gitignore for all older versions for the sake of sanity.

      This change must go into 2.5 too.

      Show
      Install grunt-cli: sudo npm install grunt-cli -g Now for moodle: npm install . And to test:   # should run shifter --walk --recursive cd path/to/moodle grunt s   # should educate you cd path/to/moodle grunt s --watch   # should run shifter --recursive cd path/to/moodle/lib/yui/src grunt s   # should run shifter --recursive --watch cd path/to/moodle/lib/yui/src grunt s --watch   # should run shifter cd path/to/moodle/lib/yui/src/tooltip grunt s   # should run shifter --watch cd path/to/moodle/lib/yui/src/tooltip grunt s --watch No changes should be seen in the build files. We will also need to add npm_modules to the .gitignore for all older versions for the sake of sanity. This change must go into 2.5 too.
    • Affected Branches:
      MOODLE_25_STABLE
    • Pull Master Branch:
      MDL-grunt-new

      Description

      Since Moodle 2.5 introduces a requirement on various external development tools, we will have a need to ensure certain versions of those tools much much more.

      As an example, Shifter minifies JS and between different versions, that minification function could change output which we want to avoid.

      At present, we recommend a single version of Shifter, but we have no way of helping developers when we change that version across different versions of Moodle.

      We could theoretically have similar issues with less/recess.

      I've worked on a few ways that we can implement this, but the easiest to work with uses Grunt (http://gruntjs.com/), in combination with a package.json to define the versions of the various dependencies.

      This means that our workflow changes from:

      # Install a specific version of shifter
      sudo npm install -g shifter@0.3.0
       
      # In the moodle root directory:
      shifter --walk --recursive
       
      # In a yui/src directory:
      shifter --recursive
       
      # In a module directory:
      shifter
      

      to:

      # Once ever.
      sudo npm install -g grunt-cli
       
      # For different branch versions (root not required):
      npm install
       
      # For any location in Moodle:
      grunt s
      

      The `npm install` part does not require privilege escalation and allows us to have different dependencies for each version of Moodle.

      This also allows us to automate various tasks much more easily. I've already written a YUIDoc processor which will generate (moodle-specific) YUI module documentation for the current version of Moodle. We should be able to do the same for less/recess once we finalise a generic format for all themes using .less files.

        Attachments

          Activity

            People

            • Assignee:
              dobedobedoh Andrew Nicols
              Reporter:
              dobedobedoh Andrew Nicols
              Peer reviewer:
              Damyon Wiese
              Participants:
              Component watchers:
              Jake Dallimore, Jun Pataleta, Bas Brands
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: