Skip to content

Commit

Permalink
Update npm configuations to be able to run npm install
Browse files Browse the repository at this point in the history
This allows us to run grunt from inside www/ instead of having to move it
to parent directory.

Also update packages

Update grunt to 0.4.5

Update grunt-contrib-copy to 1.0.0

Update grunt-contrib-jshint to 1.0.0

Update browserify to 13.0.0

Add package grunt-jsonlint for linting json files.

Change-Id: Iaf286b1dc4af2948896d2dbd37697f06b440850d
  • Loading branch information
paladox committed Mar 10, 2016
1 parent 15e7eca commit f38dfa3
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 106 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -28,7 +28,8 @@ scripts/apps
scripts/backup.ab

# Node modules for the js
www/node_modules
node_modules/
www/node_modules/
www/bundle*.js
www/abusefilter.js
www/preview.js
Expand Down
2 changes: 2 additions & 0 deletions .jshintignore
@@ -1,2 +1,4 @@
www/lib/*
app/src/main/assets/*
node_modules/
www/node_modules/
8 changes: 8 additions & 0 deletions package.json
@@ -0,0 +1,8 @@
{
"name": "wikipedia-android",
"description": "This file exists only as workaround for CI",
"private": true,
"scripts": {
"test": "cd www/ && npm install && npm test"
}
}
2 changes: 2 additions & 0 deletions www/.jshintignore
@@ -0,0 +1,2 @@
lib/*
node_modules/
18 changes: 18 additions & 0 deletions www/.jshintrc
@@ -0,0 +1,18 @@
{
"globals": {
"console": true,
"require": true,
"module": true,
"marshaller": true
},

"browser": true,
"curly": true,
"eqeqeq": true,
"forin": false,
"onevar": false,
"trailing": true,
"undef" : true,
"unused": true,
"supernew": true
}
202 changes: 109 additions & 93 deletions www/Gruntfile.js
@@ -1,100 +1,116 @@
/*jshint node:true */
module.exports = function ( grunt ) {
var allScriptFiles = [
"js/bridge.js",
"js/main.js",
"js/utilities.js",
"js/transformer.js",
"js/transforms/*.js",
"js/transforms/service/*.js",
"js/actions.js",
"js/disambig.js",
"js/editaction.js",
"js/issues.js",
"js/loader.js",
"js/night.js",
"js/preview.js",
"js/rtlsupport.js",
"js/sections.js",
"tests/*.js"
];
var allHTMLFiles = [
"index.html",
"tests/index.html"
];
var distFolder = "../app/src/main/assets/";
var allScriptFiles = [
"js/bridge.js",
"js/main.js",
"js/utilities.js",
"js/transformer.js",
"js/transforms/*.js",
"js/transforms/service/*.js",
"js/actions.js",
"js/disambig.js",
"js/editaction.js",
"js/issues.js",
"js/loader.js",
"js/night.js",
"js/preview.js",
"js/rtlsupport.js",
"js/sections.js",
"tests/*.js"
];
var allHTMLFiles = [
"index.html",
"tests/index.html"
];
var distFolder = "../app/src/main/assets/";

grunt.loadNpmTasks( 'grunt-browserify' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-contrib-copy' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-browserify' );
grunt.loadNpmTasks( 'grunt-contrib-copy' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );

grunt.initConfig( {
pkg: grunt.file.readJSON( "package.json" ),
browserify: {
dist: {
files: {
"bundle.js": [
"js/bridge.js",
"js/main.js",
"js/utilities.js",
"js/transformer.js",
"js/transforms/*.js",
"js/transforms/service/*.js",
"js/actions.js",
"js/disambig.js",
"js/editaction.js",
"js/issues.js",
"js/loader.js",
"js/night.js",
"js/preview.js",
"js/rtlsupport.js",
"js/sections.js"
],
"bundle-test.js": [
"js/loader.js",
"js/main.js",
"js/bridge.js",
"tests/*.js"
],
"preview.js": [
"js/loader.js",
"js/bridge.js",
"js/night.js",
"js/actions.js",
"js/preview.js",
"js/rtlsupport.js",
"js/util.js"
]
}
}
},
jshint: {
allFiles: allScriptFiles,
options: {
jshintrc: ".jshintrc"
}
},
copy: {
main: {
files: [
// App files
{ src: [ "bundle.js", "index.html" ], dest: distFolder },
grunt.initConfig( {
pkg: grunt.file.readJSON( "package.json" ),
jshint: {
options: {
jshintrc: true
},
all: [
'../*.js',
'**/*.js',
'!node_modules/**',
'!lib/**'
]
},
jsonlint: {
all: [
'../**/*.json',
'**/*.json',
'!../www/node_modules/**',
'!node_modules/**'
]
},
browserify: {
dist: {
files: {
"bundle.js": [
"js/bridge.js",
"js/main.js",
"js/utilities.js",
"js/transformer.js",
"js/transforms/*.js",
"js/transforms/service/*.js",
"js/actions.js",
"js/disambig.js",
"js/editaction.js",
"js/issues.js",
"js/loader.js",
"js/night.js",
"js/preview.js",
"js/rtlsupport.js",
"js/sections.js"
],
"bundle-test.js": [
"js/loader.js",
"js/main.js",
"js/bridge.js",
"tests/*.js"
],
"preview.js": [
"js/loader.js",
"js/bridge.js",
"js/night.js",
"js/actions.js",
"js/preview.js",
"js/rtlsupport.js",
"js/util.js"
]
}
}
},
copy: {
main: {
files: [
// App files
{ src: [ "bundle.js", "index.html" ], dest: distFolder },

// Test files
{ src: [ "bundle-test.js", "tests/index.html" ], dest: distFolder },
// Test files
{ src: [ "bundle-test.js", "tests/index.html" ], dest: distFolder },

// Preview files
{ src: [ "preview.js", "preview.html" ], dest: distFolder },
]
}
},
watch: {
scripts: {
files: allScriptFiles.concat( allHTMLFiles ),
tasks: [ "default" ]
}
}
} );
// Preview files
{ src: [ "preview.js", "preview.html" ], dest: distFolder },
]
}
},
watch: {
scripts: {
files: allScriptFiles.concat( allHTMLFiles ),
tasks: [ "default" ]
}
}
} );

grunt.registerTask( 'default', [ 'browserify', 'copy' ] );
grunt.registerTask( 'test', [ 'jshint', 'jsonlint', 'browserify', 'copy' ] );
grunt.registerTask( 'default', 'test' );
};
24 changes: 12 additions & 12 deletions www/package.json
@@ -1,16 +1,16 @@
{
"name": "wikipedia-android",
"description": "JS files required for the Wikipedia Android app",
"repository": "https://gerrit.wikimedia.org/r/apps/android/wikipedia",
"version": "0.1.0",
"private": true,
"scripts": {
"test": "grunt test"
},
"devDependencies": {
"browserify": "~12.0.1",
"grunt": "~0.4.2",
"grunt-browserify": "~4.0.1",
"grunt-cli": "~0.1.13",
"grunt-contrib-copy": "~0.8.2",
"grunt-contrib-jshint": "~0.11.3",
"grunt-contrib-less": "~1.1.0",
"grunt-contrib-watch": "~0.6.1"
"grunt": "0.4.5",
"grunt-cli": "0.1.13",
"browserify": "13.0.0",
"grunt-browserify": "4.0.1",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-jshint": "1.0.0",
"grunt-jsonlint": "1.0.7",
"grunt-contrib-watch": "0.6.1"
}
}

0 comments on commit f38dfa3

Please sign in to comment.