Skip to content
Snippets Groups Projects
Commit 1d1a4c31 authored by Anton Georgiev's avatar Anton Georgiev Committed by GitHub
Browse files

Merge pull request #4016 from MaximKhlobystov/grunt-to-npm-scripts-move

[HTML5 Client] Transition from Grunt to NPM Scripts
parents 3cf46a94 a25779c9
No related branches found
No related tags found
No related merge requests found
/* jshint node: true */
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
// importing the Meteor settings:
const SHELL_CONFIG = require('./private/config/server/shell.yaml');
const PROD_SHELL_CONFIG = require('./private/config/production/server/shell.yaml');
// root URL in development/production:
const rootURL = (SHELL_CONFIG.shell.rootURL == undefined)
? 'http://127.0.0.1/html5client'
: SHELL_CONFIG.shell.rootURL;
// command line string containing the Meteor's home directory in production:
const prodHomeStr = (PROD_SHELL_CONFIG.shell.home == undefined) ? ''
: (`HOME=${PROD_SHELL_CONFIG.shell.home} `);
// final commands:
const METEOR_DEV_COMMAND = `ROOT_URL=${
rootURL} NODE_ENV=development` + ' meteor';
const METEOR_PROD_COMMAND = `${prodHomeStr}ROOT_URL=${
rootURL} NODE_ENV=production` + ' meteor';
// configure Grunt
grunt.initConfig({
watch: {
scripts: {
files: ['**/*.js', '**/*.jsx'],
tasks: ['force:newer:jscs:check'],
options: {
event: ['all'],
spawn: true,
},
},
},
jscs: {
check: {
src: ['**/*.js', '**/*.jsx'],
options: {
config: '.jscsrc',
verbose: true,
esnext: true,
},
},
autofix: {
src: ['**/*.js', '**/*.jsx'],
options: {
config: '.jscsrc',
verbose: true,
esnext: true,
fix: true,
},
},
},
shell: {
start_meteor_development: {
command: METEOR_DEV_COMMAND,
},
start_meteor_production: {
command: METEOR_PROD_COMMAND,
},
},
concurrent: {
options: {
logConcurrentOutput: true,
limit: 3,
},
meteor_watch_development: {
tasks: ['shell:start_meteor_development', 'watch'],
},
meteor_watch_production: {
tasks: ['shell:start_meteor_production', 'watch'],
},
},
});
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-force-task');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-newer');
const mode = (grunt.option('mode') == 'production') ? 'production' : 'development';
// sets the default task to run JSCS first (forcing our way past warnings) and then start Meteor:
grunt.registerTask('default', ['force:newer:jscs:check', `concurrent:meteor_watch_${mode}`]);
// sets the autofix task to fix JSCS warning when possible and then start Meteor:
grunt.registerTask('autofix', ['force:newer:jscs:autofix', `concurrent:meteor_watch_${mode}`]);
// runs the linter task:
grunt.registerTask('quicklint', ['force:jscs:check']);
// runs the linter task and autofixes errors when possible:
grunt.registerTask('quickfix', ['force:jscs:autofix']);
};
GRUNT
Install all the dependencies (including grunt):
$ npm install
Running Grunt:
- for the defaults (run linter, then start Meteor):
$ grunt
- for the code style autofixing (run linter, autofix the warnings, then start Meteor):
$ grunt autofix
......@@ -2,8 +2,9 @@
"name": "bbb-html5-client",
"description": "BigBlueButton HTML5 Client",
"scripts": {
"start": "cd app;./start.sh",
"preinstall": "npm install grunt-cli",
"start": "if test \"$NODE_ENV\" = \"production\" ; then npm run start:prod; else npm run start:dev; fi",
"start:prod": "meteor reset && ROOT_URL=http://127.0.0.1/html5client NODE_ENV=production meteor --production",
"start:dev": "ROOT_URL=http://127.0.0.1/html5client NODE_ENV=development meteor",
"test": "wdio ./tests/webdriverio/wdio.conf.js",
"lint": "eslint . --ext .jsx,.js"
},
......@@ -11,7 +12,6 @@
"babel-runtime": "^6.23.0",
"classnames": "^2.2.5",
"eventemitter2": "^2.1.3",
"grunt-cli": "^1.2.0",
"hiredis": "^0.5.0",
"history": "~3.3.0",
"lodash": "~4.17.4",
......@@ -34,31 +34,23 @@
"xml2js": "^0.4.17"
},
"devDependencies": {
"chai": "^3.5.0",
"autoprefixer": "^7.1.1",
"chai": "^3.5.0",
"eslint": "~3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-config-airbnb-base": "~11.2.0",
"eslint-plugin-import": "~2.3.0",
"eslint-plugin-jsx-a11y": "^5.0.3",
"eslint-plugin-react": "^7.0.1",
"grunt": "^0.4.5",
"grunt-concurrent": "~2.2.1",
"grunt-contrib-watch": "~1.0.0",
"grunt-force-task": "~2.0.0",
"grunt-jscs": "~2.8.0",
"grunt-newer": "~1.2.0",
"grunt-shell": "~1.2.1",
"wdio-jasmine-framework": "^0.3.1",
"wdio-junit-reporter": "^0.3.0",
"wdio-spec-reporter": "^0.1.0",
"webdriverio": "^4.8.0",
"load-grunt-tasks": "~3.4.1",
"postcss-modules-extract-imports": "1.1.0",
"postcss-modules-local-by-default": "1.2.0",
"postcss-modules-scope": "1.1.0",
"postcss-modules-values": "1.3.0",
"postcss-nested": "2.0.2"
"postcss-nested": "2.0.2",
"wdio-jasmine-framework": "^0.3.1",
"wdio-junit-reporter": "^0.3.0",
"wdio-spec-reporter": "^0.1.0",
"webdriverio": "^4.8.0"
},
"cssModules": {
"extensions": [
......
shell:
home: "/usr/share/meteor"
shell:
rootURL: "http://127.0.0.1/html5client"
#!/bin/bash
# Change to start meteor in production or development mode
ENVIRONMENT_TYPE=development
ROOT_URL=http://127.0.0.1/html5client NODE_ENV=$ENVIRONMENT_TYPE meteor
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment