1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00
node-red/Gruntfile.js

605 lines
27 KiB
JavaScript
Raw Normal View History

2014-06-28 22:40:46 +02:00
/**
* Copyright JS Foundation and other contributors, http://js.foundation
2014-06-28 22:40:46 +02:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
2015-04-02 00:24:47 +02:00
var path = require("path");
2015-04-16 12:53:39 +02:00
2014-03-31 14:31:31 +02:00
module.exports = function(grunt) {
2015-04-16 12:53:39 +02:00
var nodemonArgs = ["-v"];
var flowFile = grunt.option('flowFile');
if (flowFile) {
nodemonArgs.push(flowFile);
}
2018-07-10 13:42:56 +02:00
var nonHeadless = grunt.option('non-headless');
if (nonHeadless) {
process.env.NODE_RED_NON_HEADLESS = 'true';
}
2014-03-31 14:31:31 +02:00
grunt.initConfig({
2015-04-02 00:24:47 +02:00
pkg: grunt.file.readJSON('package.json'),
paths: {
dist: ".dist"
},
simplemocha: {
options: {
globals: ['expect'],
timeout: 3000,
ignoreLeaks: false,
ui: 'bdd',
reporter: 'spec'
},
all: { src: ['test/**/*_spec.js'] },
2018-08-20 17:17:24 +02:00
core: { src: ["test/_spec.js","test/unit/**/*_spec.js"]},
2015-04-02 00:24:47 +02:00
nodes: { src: ["test/nodes/**/*_spec.js"]}
},
2017-12-01 11:50:59 +01:00
webdriver: {
all: {
configFile: 'test/editor/wdio.conf.js'
}
},
2017-03-09 16:28:13 +01:00
mocha_istanbul: {
options: {
globals: ['expect'],
timeout: 3000,
ignoreLeaks: false,
ui: 'bdd',
reportFormats: ['lcov','html'],
2018-10-25 14:36:57 +02:00
print: 'both',
istanbulOptions: ['--no-default-excludes', '-i','**/packages/node_modules/**']
2017-03-09 16:28:13 +01:00
},
2018-08-20 17:17:24 +02:00
all: { src: ["test/unit/_spec.js","test/unit/**/*_spec.js","test/nodes/**/*_spec.js"] },
core: { src: ["test/unit/_spec.js","test/unit/**/*_spec.js"]},
nodes: { src: ["test/nodes/**/*_spec.js"]}
2017-03-09 16:28:13 +01:00
},
2015-04-02 00:24:47 +02:00
jshint: {
options: {
2015-04-16 12:53:39 +02:00
jshintrc:true
2015-04-02 00:24:47 +02:00
// http://www.jshint.com/docs/options/
2015-04-16 12:53:39 +02:00
//"asi": true, // allow missing semicolons
//"curly": true, // require braces
//"eqnull": true, // ignore ==null
//"forin": true, // require property filtering in "for in" loops
//"immed": true, // require immediate functions to be wrapped in ( )
//"nonbsp": true, // warn on unexpected whitespace breaking chars
////"strict": true, // commented out for now as it causes 100s of warnings, but want to get there eventually
//"loopfunc": true, // allow functions to be defined in loops
//"sub": true // don't warn that foo['bar'] should be written as foo.bar
2015-04-02 00:24:47 +02:00
},
all: [
'Gruntfile.js',
'red.js',
2018-08-04 23:23:06 +02:00
'packages/**/*.js'
2015-04-02 00:24:47 +02:00
],
core: {
files: {
src: [
'Gruntfile.js',
'red.js',
2018-08-04 23:23:06 +02:00
'packages/**/*.js',
2015-04-02 00:24:47 +02:00
]
}
},
nodes: {
files: {
src: [ 'nodes/core/*/*.js' ]
2015-04-02 00:24:47 +02:00
}
},
editor: {
files: {
src: [ 'editor/js/**/*.js' ]
}
},
tests: {
files: {
src: ['test/**/*.js']
2014-03-31 14:31:31 +02:00
},
2015-04-02 00:24:47 +02:00
options: {
2016-05-18 12:11:59 +02:00
"expr": true
2015-04-02 00:24:47 +02:00
}
}
},
concat: {
options: {
separator: ";",
2014-06-28 22:40:46 +02:00
},
2015-04-02 00:24:47 +02:00
build: {
2016-05-18 12:11:59 +02:00
src: [
// Ensure editor source files are concatenated in
// the right order
2018-10-24 23:57:16 +02:00
"packages/node_modules/@node-red/editor-client/src/js/jquery-addons.js",
2018-08-17 23:10:54 +02:00
"packages/node_modules/@node-red/editor-client/src/js/red.js",
"packages/node_modules/@node-red/editor-client/src/js/events.js",
"packages/node_modules/@node-red/editor-client/src/js/i18n.js",
"packages/node_modules/@node-red/editor-client/src/js/settings.js",
"packages/node_modules/@node-red/editor-client/src/js/user.js",
"packages/node_modules/@node-red/editor-client/src/js/comms.js",
"packages/node_modules/@node-red/editor-client/src/js/text/bidi.js",
"packages/node_modules/@node-red/editor-client/src/js/text/format.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/state.js",
"packages/node_modules/@node-red/editor-client/src/js/nodes.js",
"packages/node_modules/@node-red/editor-client/src/js/font-awesome.js",
2018-08-17 23:10:54 +02:00
"packages/node_modules/@node-red/editor-client/src/js/history.js",
"packages/node_modules/@node-red/editor-client/src/js/validators.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/utils.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/editableList.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/checkboxSet.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/menu.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/panels.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/popover.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/searchBox.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/tabs.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/stack.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/actions.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/diff.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/keyboard.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/workspaces.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/view.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/view-navigator.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/sidebar.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/palette.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/tab-info.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/tab-config.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/tab-context.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/palette-editor.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/editor.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/editors/*.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/event-log.js",
2018-08-17 23:10:54 +02:00
"packages/node_modules/@node-red/editor-client/src/js/ui/tray.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/clipboard.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/library.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/notifications.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/search.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/userSettings.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/projects/projects.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/projects/projectSettings.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/projects/projectUserSettings.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/projects/tab-versionControl.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/touch/radialMenu.js"
2016-05-18 12:11:59 +02:00
],
2018-08-17 23:10:54 +02:00
dest: "packages/node_modules/@node-red/editor-client/public/red/red.js"
},
vendor: {
files: {
2018-08-17 23:10:54 +02:00
"packages/node_modules/@node-red/editor-client/public/vendor/vendor.js": [
"packages/node_modules/@node-red/editor-client/src/vendor/jquery/js/jquery-1.11.3.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/bootstrap/js/bootstrap.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/jquery/js/jquery.ui.touch-punch.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/marked/marked.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/d3/d3.v3.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/i18next/i18next.min.js"
],
2018-08-17 23:10:54 +02:00
"packages/node_modules/@node-red/editor-client/public/vendor/vendor.css": [
// TODO: resolve relative resource paths in
// bootstrap/FA/jquery
2016-11-16 00:22:25 +01:00
],
2018-08-17 23:10:54 +02:00
"packages/node_modules/@node-red/editor-client/public/vendor/jsonata/jsonata.min.js": [
2017-06-26 14:55:22 +02:00
"node_modules/jsonata/jsonata-es5.min.js",
2018-08-17 23:10:54 +02:00
"packages/node_modules/@node-red/editor-client/src/vendor/jsonata/formatter.js"
2017-06-26 14:55:22 +02:00
],
2018-08-17 23:10:54 +02:00
"packages/node_modules/@node-red/editor-client/public/vendor/ace/worker-jsonata.js": [
2017-06-26 14:55:22 +02:00
"node_modules/jsonata/jsonata-es5.min.js",
2018-08-17 23:10:54 +02:00
"packages/node_modules/@node-red/editor-client/src/vendor/jsonata/worker-jsonata.js"
]
}
2015-04-02 00:24:47 +02:00
}
},
uglify: {
build: {
files: {
2018-08-17 23:10:54 +02:00
'packages/node_modules/@node-red/editor-client/public/red/red.min.js': 'packages/node_modules/@node-red/editor-client/public/red/red.js',
'packages/node_modules/@node-red/editor-client/public/red/main.min.js': 'packages/node_modules/@node-red/editor-client/public/red/main.js',
'packages/node_modules/@node-red/editor-client/public/vendor/ace/mode-jsonata.js': 'packages/node_modules/@node-red/editor-client/src/vendor/jsonata/mode-jsonata.js',
'packages/node_modules/@node-red/editor-client/public/vendor/ace/snippets/jsonata.js': 'packages/node_modules/@node-red/editor-client/src/vendor/jsonata/snippets-jsonata.js'
2015-04-02 00:24:47 +02:00
}
}
},
sass: {
build: {
2014-06-28 22:40:46 +02:00
options: {
2015-04-02 00:24:47 +02:00
outputStyle: 'compressed'
2014-06-28 22:40:46 +02:00
},
2015-04-02 00:24:47 +02:00
files: [{
2018-08-17 23:10:54 +02:00
dest: 'packages/node_modules/@node-red/editor-client/public/red/style.min.css',
src: 'packages/node_modules/@node-red/editor-client/src/sass/style.scss'
2015-07-13 12:26:29 +02:00
},
{
2018-08-17 23:10:54 +02:00
dest: 'packages/node_modules/@node-red/editor-client/public/vendor/bootstrap/css/bootstrap.min.css',
src: 'packages/node_modules/@node-red/editor-client/src/vendor/bootstrap/css/bootstrap.css'
2015-04-02 00:24:47 +02:00
}]
}
},
2015-05-28 16:28:17 +02:00
jsonlint: {
messages: {
src: [
2018-09-06 16:16:43 +02:00
'packages/node_modules/@node-red/nodes/locales/**/*.json',
'packages/node_modules/@node-red/editor-client/locales/**/*.json',
2018-09-06 16:16:43 +02:00
'packages/node_modules/@node-red/runtime/locales/**/*.json'
2015-05-28 16:28:17 +02:00
]
},
keymaps: {
src: [
2018-08-17 23:10:54 +02:00
'packages/node_modules/@node-red/editor-client/src/js/keymap.json'
]
2015-05-28 16:28:17 +02:00
}
},
attachCopyright: {
js: {
src: [
2018-08-17 23:10:54 +02:00
'packages/node_modules/@node-red/editor-client/public/red/red.min.js',
'packages/node_modules/@node-red/editor-client/public/red/main.min.js'
]
},
css: {
src: [
2018-08-17 23:10:54 +02:00
'packages/node_modules/@node-red/editor-client/public/red/style.min.css'
]
}
},
2015-04-02 00:24:47 +02:00
clean: {
build: {
src: [
2018-08-17 23:10:54 +02:00
"packages/node_modules/@node-red/editor-client/public/red",
"packages/node_modules/@node-red/editor-client/public/index.html",
"packages/node_modules/@node-red/editor-client/public/favicon.ico",
"packages/node_modules/@node-red/editor-client/public/icons",
"packages/node_modules/@node-red/editor-client/public/vendor"
2015-04-02 00:24:47 +02:00
]
},
release: {
src: [
'<%= paths.dist %>'
]
}
},
watch: {
js: {
files: [
2018-08-17 23:10:54 +02:00
'packages/node_modules/@node-red/editor-client/src/js/**/*.js'
2014-06-28 22:40:46 +02:00
],
tasks: ['copy:build','concat','uglify','attachCopyright:js']
2015-04-02 00:24:47 +02:00
},
sass: {
files: [
2018-08-17 23:10:54 +02:00
'packages/node_modules/@node-red/editor-client/src/sass/**/*.scss'
2015-04-02 00:24:47 +02:00
],
tasks: ['sass','attachCopyright:css']
2015-05-28 16:28:17 +02:00
},
json: {
files: [
2018-09-06 16:16:43 +02:00
'packages/node_modules/@node-red/nodes/locales/**/*.json',
'packages/node_modules/@node-red/editor-client/locales/**/*.json',
2018-09-06 16:16:43 +02:00
'packages/node_modules/@node-red/runtime/locales/**/*.json'
2015-05-28 16:28:17 +02:00
],
tasks: ['jsonlint:messages']
},
keymaps: {
files: [
2018-08-17 23:10:54 +02:00
'packages/node_modules/@node-red/editor-client/src/js/keymap.json'
],
tasks: ['jsonlint:keymaps','copy:build']
},
misc: {
files: [
'CHANGELOG.md'
],
tasks: ['copy:build']
2015-04-02 00:24:47 +02:00
}
},
2015-04-16 12:53:39 +02:00
2015-04-02 00:24:47 +02:00
nodemon: {
/* uses .nodemonignore */
dev: {
script: 'packages/node_modules/node-red/red.js',
2015-04-02 00:24:47 +02:00
options: {
args: nodemonArgs,
2015-05-28 16:28:17 +02:00
ext: 'js,html,json',
2015-04-09 23:18:37 +02:00
watch: [
2018-09-06 16:16:43 +02:00
'packages/node_modules',
'!packages/node_modules/@node-red/editor-client'
2015-04-09 23:18:37 +02:00
]
2015-04-02 00:24:47 +02:00
}
}
},
2015-04-16 12:53:39 +02:00
2015-04-02 00:24:47 +02:00
concurrent: {
dev: {
tasks: ['nodemon', 'watch'],
options: {
logConcurrentOutput: true
}
}
},
2015-04-16 12:53:39 +02:00
2015-04-02 00:24:47 +02:00
copy: {
build: {
2016-11-02 23:53:18 +01:00
files:[
{
2018-08-17 23:10:54 +02:00
src: 'packages/node_modules/@node-red/editor-client/src/js/main.js',
dest: 'packages/node_modules/@node-red/editor-client/public/red/main.js'
2016-11-02 23:53:18 +01:00
},
{
2018-08-17 23:10:54 +02:00
src: 'packages/node_modules/@node-red/editor-client/src/js/keymap.json',
dest: 'packages/node_modules/@node-red/editor-client/public/red/keymap.json'
},
2016-11-02 23:53:18 +01:00
{
2018-08-17 23:10:54 +02:00
cwd: 'packages/node_modules/@node-red/editor-client/src/images',
2016-11-02 23:53:18 +01:00
src: '**',
expand: true,
2018-08-17 23:10:54 +02:00
dest: 'packages/node_modules/@node-red/editor-client/public/red/images/'
2016-11-02 23:53:18 +01:00
},
{
2018-08-17 23:10:54 +02:00
cwd: 'packages/node_modules/@node-red/editor-client/src/vendor',
2016-11-02 23:53:18 +01:00
src: [
'ace/**',
//'bootstrap/css/**',
'bootstrap/img/**',
'jquery/css/**',
'font-awesome/**'
],
expand: true,
2018-08-17 23:10:54 +02:00
dest: 'packages/node_modules/@node-red/editor-client/public/vendor/'
2016-11-02 23:53:18 +01:00
},
{
2018-08-17 23:10:54 +02:00
cwd: 'packages/node_modules/@node-red/editor-client/src/icons',
2016-11-02 23:53:18 +01:00
src: '**',
expand: true,
2018-08-17 23:10:54 +02:00
dest: 'packages/node_modules/@node-red/editor-client/public/icons/'
2016-11-02 23:53:18 +01:00
},
{
expand: true,
2018-08-17 23:10:54 +02:00
src: ['packages/node_modules/@node-red/editor-client/src/index.html','packages/node_modules/@node-red/editor-client/src/favicon.ico'],
dest: 'packages/node_modules/@node-red/editor-client/public/',
2016-11-02 23:53:18 +01:00
flatten: true
},
{
src: 'CHANGELOG.md',
2018-08-17 23:10:54 +02:00
dest: 'packages/node_modules/@node-red/editor-client/public/red/about'
},
{
src: 'CHANGELOG.md',
dest: 'packages/node_modules/node-red/'
},
{
cwd: 'packages/node_modules/@node-red/editor-client/src/ace/bin/',
src: '**',
expand: true,
dest: 'packages/node_modules/@node-red/editor-client/public/vendor/ace/'
2016-11-02 23:53:18 +01:00
}
]
2015-04-02 00:24:47 +02:00
}
},
chmod: {
options: {
mode: '755'
},
release: {
src: [
"packages/node_modules/@node-red/nodes/core/hardware/nrgpio",
"packages/node_modules/@node-red/runtime/lib/storage/localfilesystem/projects/git/node-red-*sh"
]
}
},
2018-10-25 12:18:13 +02:00
'npm-command': {
options: {
cmd: "pack",
cwd: "<%= paths.dist %>/modules"
},
'node-red': { options: { args: [__dirname+'/packages/node_modules/node-red'] } },
'@node-red/editor-api': { options: { args: [__dirname+'/packages/node_modules/@node-red/editor-api'] } },
'@node-red/editor-client': { options: { args: [__dirname+'/packages/node_modules/@node-red/editor-client'] } },
'@node-red/nodes': { options: { args: [__dirname+'/packages/node_modules/@node-red/nodes'] } },
'@node-red/registry': { options: { args: [__dirname+'/packages/node_modules/@node-red/registry'] } },
'@node-red/runtime': { options: { args: [__dirname+'/packages/node_modules/@node-red/runtime'] } },
'@node-red/util': { options: { args: [__dirname+'/packages/node_modules/@node-red/util'] } }
},
mkdir: {
release: {
options: {
create: ['<%= paths.dist %>/modules']
},
},
},
2015-04-02 00:24:47 +02:00
compress: {
release: {
options: {
archive: '<%= paths.dist %>/node-red-<%= pkg.version %>.zip'
},
expand: true,
cwd: 'packages/node_modules/',
src: [
'**',
'!@node-red/editor-client/src/**'
]
2014-03-31 14:31:31 +02:00
}
2018-04-24 17:48:32 +02:00
},
jsdoc : {
2018-12-05 14:00:25 +01:00
modules: {
src: [
'packages/node_modules/node-red/lib/red.js',
'packages/node_modules/@node-red/runtime/lib/index.js',
'packages/node_modules/@node-red/runtime/lib/api/*.js',
2018-12-05 14:00:25 +01:00
'packages/node_modules/@node-red/runtime/lib/events.js',
'packages/node_modules/@node-red/util/**/*.js',
],
2018-04-24 17:48:32 +02:00
options: {
destination: 'docs',
configure: './jsdoc.json'
}
},
editor: {
src: [
'packages/node_modules/@node-red/editor-client/src/js'
],
options: {
destination: 'packages/node_modules/@node-red/editor-client/docs',
configure: './jsdoc.json'
}
2018-04-24 17:48:32 +02:00
}
2018-04-24 17:48:32 +02:00
},
jsdoc2md: {
runtimeAPI: {
options: {
separators: true
},
2018-12-05 14:00:25 +01:00
src: [
'packages/node_modules/@node-red/runtime/lib/index.js',
'packages/node_modules/@node-red/runtime/lib/api/*.js',
'packages/node_modules/@node-red/runtime/lib/events.js'
],
dest: 'packages/node_modules/@node-red/runtime/docs/api.md'
2018-08-22 11:00:03 +02:00
},
nodeREDUtil: {
options: {
separators: true
},
src: 'packages/node_modules/@node-red/util/**/*.js',
dest: 'packages/node_modules/@node-red/util/docs/api.md'
2018-04-24 17:48:32 +02:00
}
2015-04-02 00:24:47 +02:00
}
2014-03-31 14:31:31 +02:00
});
2015-04-16 12:53:39 +02:00
2014-03-31 14:31:31 +02:00
grunt.loadNpmTasks('grunt-simple-mocha');
2014-06-28 22:40:46 +02:00
grunt.loadNpmTasks('grunt-contrib-jshint');
2015-04-02 00:24:47 +02:00
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-chmod');
2015-05-28 16:28:17 +02:00
grunt.loadNpmTasks('grunt-jsonlint');
2017-03-09 16:28:13 +01:00
grunt.loadNpmTasks('grunt-mocha-istanbul');
2017-12-01 11:50:59 +01:00
grunt.loadNpmTasks('grunt-webdriver');
2018-04-24 17:48:32 +02:00
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-jsdoc-to-markdown');
2018-10-25 12:18:13 +02:00
grunt.loadNpmTasks('grunt-npm-command');
grunt.loadNpmTasks('grunt-mkdir');
grunt.registerMultiTask('attachCopyright', function() {
var files = this.data.src;
var copyright = "/**\n"+
" * Copyright JS Foundation and other contributors, http://js.foundation\n"+
" *\n"+
" * Licensed under the Apache License, Version 2.0 (the \"License\");\n"+
" * you may not use this file except in compliance with the License.\n"+
" * You may obtain a copy of the License at\n"+
" *\n"+
" * http://www.apache.org/licenses/LICENSE-2.0\n"+
" *\n"+
" * Unless required by applicable law or agreed to in writing, software\n"+
" * distributed under the License is distributed on an \"AS IS\" BASIS,\n"+
" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"+
" * See the License for the specific language governing permissions and\n"+
" * limitations under the License.\n"+
" **/\n";
2015-04-16 12:53:39 +02:00
if (files) {
for (var i=0; i<files.length; i++) {
var file = files[i];
if (!grunt.file.exists(file)) {
grunt.log.warn('File '+ file + ' not found');
return false;
} else {
var content = grunt.file.read(file);
if (content.indexOf(copyright) == -1) {
content = copyright+content;
if (!grunt.file.write(file, content)) {
return false;
}
grunt.log.writeln("Attached copyright to "+file);
} else {
grunt.log.writeln("Copyright already on "+file);
}
}
}
}
});
grunt.registerTask('verifyPackageDependencies', function() {
2018-12-07 15:13:59 +01:00
var done = this.async();
var verifyDependencies = require("./scripts/verify-package-dependencies.js");
2018-12-07 15:13:59 +01:00
verifyDependencies().then(function(failures) {
if (failures.length > 0) {
failures.forEach(f => grunt.log.error(f));
grunt.fail.fatal("Failed to verify package dependencies");
}
done();
});
});
grunt.registerTask('setDevEnv',
'Sets NODE_ENV=development so non-minified assets are used',
function () {
process.env.NODE_ENV = 'development';
});
2015-04-02 00:24:47 +02:00
grunt.registerTask('default',
'Builds editor content then runs code style checks and unit tests on all components',
['build','verifyPackageDependencies','jshint:editor','mocha_istanbul:all']);
2015-04-16 12:53:39 +02:00
2015-04-02 00:24:47 +02:00
grunt.registerTask('test-core',
'Runs code style check and unit tests on core runtime code',
['build','mocha_istanbul:core']);
2015-04-16 12:53:39 +02:00
2015-04-02 00:24:47 +02:00
grunt.registerTask('test-editor',
'Runs code style check on editor code',
['jshint:editor']);
2015-04-16 12:53:39 +02:00
2017-12-01 11:50:59 +01:00
grunt.registerTask('test-ui',
'Builds editor content then runs unit tests on editor ui',
['build','jshint:editor','webdriver:all']);
2015-04-02 00:24:47 +02:00
grunt.registerTask('test-nodes',
'Runs unit tests on core nodes',
['build','mocha_istanbul:nodes']);
2015-04-16 12:53:39 +02:00
2015-04-02 00:24:47 +02:00
grunt.registerTask('build',
'Builds editor content',
['clean:build','jsonlint','concat:build','concat:vendor','copy:build','uglify:build','sass:build','attachCopyright']);
2015-04-16 12:53:39 +02:00
2015-04-02 00:24:47 +02:00
grunt.registerTask('dev',
'Developer mode: run node-red, watch for source changes and build/restart',
['build','setDevEnv','concurrent:dev']);
2015-04-16 12:53:39 +02:00
2015-04-02 00:24:47 +02:00
grunt.registerTask('release',
'Create distribution zip file',
2018-10-25 12:18:13 +02:00
['build','verifyPackageDependencies','clean:release','mkdir:release','chmod:release','compress:release','pack-modules']);
grunt.registerTask('pack-modules',
'Create module pack files for release',
['mkdir:release','npm-command']);
2015-04-02 00:24:47 +02:00
grunt.registerTask('coverage',
'Run Istanbul code test coverage task',
['build','mocha_istanbul:all']);
2018-04-24 17:48:32 +02:00
grunt.registerTask('docs',
'Generates API documentation',
['jsdoc','jsdoc2md']);
2014-03-31 14:31:31 +02:00
};