-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
2,091 additions
and
3,844 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Description | ||
|
||
|
||
## Testing | ||
<!-- How and what have you tested? What needs later verification? --> | ||
|
||
|
||
## Jira Link | ||
<!-- E.g. PC-### (link to Jira will populate automatically). Optional and Jira# must still be added to the PR title. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,152 +1,41 @@ | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
/* jshint node: true, browser: false */ | ||
/* eslint-env node */ | ||
|
||
/** | ||
* @copyright 2021 Panopto | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
/** | ||
* Grunt configuration | ||
*/ | ||
|
||
/* eslint-env node */ | ||
module.exports = function(grunt) { | ||
var path = require('path'), | ||
tasks = {}, | ||
cwd = process.env.PWD || process.cwd(), | ||
async = require('async'); | ||
|
||
// Windows users can't run grunt in a subdirectory, so allow them to set | ||
// the root by passing --root=path/to/dir. | ||
if (grunt.option('root')) { | ||
var root = grunt.option('root'); | ||
if (grunt.file.exists(__dirname, root)) { | ||
cwd = path.join(__dirname, root); | ||
grunt.log.ok('Setting root to ' + cwd); | ||
} else { | ||
grunt.fail.fatal('Setting root to ' + root + ' failed - path does not exist'); | ||
} | ||
} | ||
|
||
var files = null; | ||
if (grunt.option('files')) { | ||
// Accept a comma separated list of files to process. | ||
files = grunt.option('files').split(','); | ||
} | ||
|
||
module.exports = function (grunt) { | ||
// Project configuration. | ||
grunt.initConfig({ | ||
shifter: { | ||
options: { | ||
recursive: true, | ||
paths: files ? files : [cwd] | ||
} | ||
} | ||
pkg: grunt.file.readJSON("package.json"), | ||
|
||
// Configuration for uglify task to minify JS files. | ||
uglify: { | ||
build: { | ||
files: [ | ||
{ | ||
expand: true, | ||
cwd: "amd/src", | ||
src: "*.js", | ||
dest: "amd/build", | ||
ext: ".min.js", | ||
}, | ||
], | ||
}, | ||
}, | ||
|
||
// Configuration for watch task to monitor changes in JS files. | ||
watch: { | ||
scripts: { | ||
files: ["amd/src/**/*.js"], | ||
tasks: ["uglify"], | ||
options: { | ||
spawn: false, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
/** | ||
* Shifter task. Is configured with a path to a specific file or a directory, | ||
* in the case of a specific file it will work out the right module to be built. | ||
* | ||
* Note that this task runs the invidiaul shifter jobs async (becase it spawns | ||
* so be careful to to call done(). | ||
*/ | ||
tasks.shifter = function() { | ||
var done = this.async(), | ||
options = grunt.config('shifter.options'); | ||
|
||
// Run the shifter processes one at a time to avoid confusing output. | ||
async.eachSeries(options.paths, function(src, filedone) { | ||
var args = []; | ||
args.push(path.normalize(__dirname + '/node_modules/shifter/bin/shifter')); | ||
|
||
// Always ignore the node_modules directory. | ||
args.push('--excludes', 'node_modules'); | ||
|
||
// Determine the most appropriate options to run with based upon the current location. | ||
if (grunt.file.isMatch('**/yui/**/*.js', src)) { | ||
// When passed a JS file, build our containing module (this happen with | ||
// watch). | ||
grunt.log.debug('Shifter passed a specific JS file'); | ||
src = path.dirname(path.dirname(src)); | ||
options.recursive = false; | ||
} else if (grunt.file.isMatch('**/yui/src', src)) { | ||
// When in a src directory --walk all modules. | ||
grunt.log.debug('In a src directory'); | ||
args.push('--walk'); | ||
options.recursive = false; | ||
} else if (grunt.file.isMatch('**/yui/src/*', src)) { | ||
// When in module, only build our module. | ||
grunt.log.debug('In a module directory'); | ||
options.recursive = false; | ||
} else if (grunt.file.isMatch('**/yui/src/*/js', src)) { | ||
// When in module src, only build our module. | ||
grunt.log.debug('In a source directory'); | ||
src = path.dirname(src); | ||
options.recursive = false; | ||
} | ||
|
||
// Add the stderr option if appropriate | ||
if (grunt.option('verbose')) { | ||
args.push('--lint-stderr'); | ||
} | ||
|
||
if (grunt.option('no-color')) { | ||
args.push('--color=false'); | ||
} | ||
|
||
var execShifter = function() { | ||
|
||
grunt.log.ok("Running shifter on " + src); | ||
grunt.util.spawn({ | ||
cmd: "node", | ||
args: args, | ||
opts: {cwd: src, stdio: 'inherit', env: process.env} | ||
}, function(error, result, code) { | ||
if (code) { | ||
grunt.fail.fatal('Shifter failed with code: ' + code); | ||
} else { | ||
grunt.log.ok('Shifter build complete.'); | ||
filedone(); | ||
} | ||
}); | ||
}; | ||
|
||
// Actually run shifter. | ||
if (!options.recursive) { | ||
execShifter(); | ||
} else { | ||
// Check that there are yui modules otherwise shifter ends with exit code 1. | ||
if (grunt.file.expand({cwd: src}, '**/yui/src/**/*.js').length > 0) { | ||
args.push('--recursive'); | ||
execShifter(); | ||
} else { | ||
grunt.log.ok('No YUI modules to build.'); | ||
filedone(); | ||
} | ||
} | ||
}, done); | ||
}; | ||
|
||
// Register JS tasks. | ||
grunt.registerTask('shifter', 'Run Shifter against the current directory', tasks.shifter); | ||
// Load the plugin that provides the "uglify" task. | ||
grunt.loadNpmTasks("grunt-contrib-uglify"); | ||
|
||
// Load the plugin that provides the "watch" task. | ||
grunt.loadNpmTasks("grunt-contrib-watch"); | ||
|
||
// Register the default task. | ||
grunt.registerTask('default', ['shifter']); | ||
// Default task(s). | ||
grunt.registerTask("default", ["uglify", "watch"]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.