jenkins-bot has submitted this change and it was merged. Change subject: Introduce grunt deploy ......................................................................
Introduce grunt deploy Bug: T137623 Change-Id: Icd62f69f06ea4cff9ecbc769905373fac2017a4e --- M Gruntfile.js M README.md M package.json 3 files changed, 102 insertions(+), 43 deletions(-) Approvals: Smalyshev: Looks good to me, approved jenkins-bot: Verified diff --git a/Gruntfile.js b/Gruntfile.js index 4ab7489..d9fc11c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,21 +1,9 @@ /* jshint node:true */ module.exports = function( grunt ) { 'use strict'; - grunt.loadNpmTasks( 'grunt-banana-checker' ); - grunt.loadNpmTasks( 'grunt-contrib-jshint' ); - grunt.loadNpmTasks( 'grunt-contrib-qunit' ); - grunt.loadNpmTasks( 'grunt-jsonlint' ); - grunt.loadNpmTasks( 'grunt-jscs' ); - grunt.loadNpmTasks( 'grunt-usemin' ); - grunt.loadNpmTasks( 'grunt-filerev' ); - grunt.loadNpmTasks( 'grunt-contrib-clean' ); - grunt.loadNpmTasks( 'grunt-contrib-concat' ); - grunt.loadNpmTasks( 'grunt-contrib-uglify' ); - grunt.loadNpmTasks( 'grunt-contrib-copy' ); - grunt.loadNpmTasks( 'grunt-contrib-cssmin' ); - grunt.loadNpmTasks( 'grunt-contrib-htmlmin' ); - + require( 'load-grunt-tasks' )( grunt ); var pkg = grunt.file.readJSON( 'package.json' ); + var dist = 'dist'; grunt.initConfig( { pkg: pkg, @@ -45,13 +33,18 @@ }, clean: { release: [ - 'dist' + dist + ], + deploy: [ + dist + '/*', dist + '!.git/**' ] }, useminPrepare: { - html: ['index.html', 'embed.html'], + html: [ + 'index.html', 'embed.html' + ], options: { - dest: 'dist' + dest: dist } }, concat: {}, @@ -59,13 +52,13 @@ copy: { release: { files: [ - {//bootstrap icons + {// bootstrap icons expand: true, flatten: true, src: [ '**/*.{eot,ttf,woff,woff2}' ], - dest: 'dist/fonts/', + dest: dist + '/fonts/', filter: 'isFile' }, {// uls images @@ -74,7 +67,7 @@ src: [ '**/jquery.uls/images/*.{png,jpg,svg}' ], - dest: 'dist/images/', + dest: dist + '/images/', filter: 'isFile' }, {// leaflet fullscreen images @@ -83,17 +76,17 @@ src: [ '**/leaflet-fullscreen/**/*.png' ], - dest: 'dist/css/', + dest: dist + '/css/', filter: 'isFile' }, { expand: true, cwd: './', src: [ - 'i18n/**', 'vendor/jquery.uls/**', '*.html', 'logo.svg', - 'robots.txt' + 'i18n/**', 'vendor/jquery.uls/**', '*.html', + 'logo.svg', 'robots.txt' ], - dest: 'dist' + dest: dist } ] } @@ -113,7 +106,7 @@ files: [ { src: [ - 'dist/js/*.js', 'dist/css/*.css' + dist + '/js/*.js', dist + '/css/*.css' ] } ] @@ -121,7 +114,7 @@ }, usemin: { html: [ - 'dist/index.html', 'dist/embed.html' + dist + '/index.html', dist + '/embed.html' ] }, htmlmin: { @@ -130,19 +123,64 @@ removeComments: true, collapseWhitespace: true }, - files: { - 'dist/index.html': 'dist/index.html' + files: [ + { + expand: true, + cwd: dist, + src: '**/*.html', + dest: dist + } + ] + } + }, + shell: { + options: { + execOptions: { + shell: '/bin/sh' } + }, + updateRepo: {// updates the gui repo + command: 'git remote update && git pull' + }, + cloneDeploy: {// clone gui deploy to dist folder + command: 'git clone --branch <%= pkg.repository.deploy.branch %>' + + ' --single-branch https://<%= pkg.repository.deploy.gerrit %>/r/<%= pkg.repository.deploy.repo %> ' + + dist + }, + commitDeploy: {// get gui commit message and use it for deploy commit + command: [ + 'lastrev=$(git rev-parse HEAD)', + 'message=$(git log -1 --pretty=%B)', + 'newmessage=$(cat <<END\nMerging from $lastrev:\n\n$message\nEND\n)', + 'cd ' + dist, + 'git add -A', 'git commit -m "$newmessage"', + 'echo "$newmessage"', 'git review' + ].join( '&&' ) } } + } ); + + grunt.registerTask( 'configDeploy', 'Creates .git-review in dist folder', function() { + var file = '[gerrit]\nhost=' + pkg.repository.deploy.gerrit + '\n' + + 'port=29418\n' + + 'project=' + pkg.repository.deploy.repo + '.git\n' + + 'defaultbranch=' + pkg.repository.deploy.branch + '\n' + + 'defaultrebase=0\n'; + + grunt.file.write( dist + '/.gitreview', file ); } ); grunt.registerTask( 'test', [ 'jshint', 'jscs', 'jsonlint', 'banana', 'qunit' ] ); grunt.registerTask( 'build', [ - 'clean', 'copy', 'useminPrepare', 'concat', 'cssmin', 'uglify', 'filerev', 'usemin', - 'htmlmin' + 'clean', 'build_dist' + ] ); + grunt.registerTask( 'build_dist', [ + 'copy', 'useminPrepare', 'concat', 'cssmin', 'uglify', 'filerev', 'usemin', 'htmlmin' + ] ); + grunt.registerTask( 'deploy', [ + 'clean', 'shell:updateRepo', 'shell:cloneDeploy', 'clean:deploy', 'build_dist', 'configDeploy','shell:commitDeploy' ] ); grunt.registerTask( 'default', 'test' ); }; diff --git a/README.md b/README.md index 9738d86..0782421 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Please see more details about the service in the [User Manual](https://www.mediawiki.org/wiki/Wikidata_query_service/User_Manual). -#Download +#Download & setup Clone git repo, go into created folder and then pull all dependencies via npm package manager. @@ -27,4 +27,18 @@ ```bash $ grunt build +``` + + +#Deploy +Creates a build and pushes it to the deployment branch via git review + +```bash +$ grunt deploy +``` + + +Please make sure you have defined a gitreview username: +```bash +git config --global --add gitreview.username "[username]" ``` \ No newline at end of file diff --git a/package.json b/package.json index c2f29b2..28576c9 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,12 @@ }, "repository": { "type": "git", - "url": "https://gerrit.wikimedia.org/r/p/wikidata/query/gui.git" + "url": "https://gerrit.wikimedia.org/r/p/wikidata/query/gui.git", + "deploy": { + "gerrit": "gerrit.wikimedia.org", + "repo": "wikidata/query/gui-deploy", + "branch": "production" + } }, "dependencies": { "jquery": "^1.12.0", @@ -30,22 +35,24 @@ }, "devDependencies": { "grunt": "0.4.5", + "grunt-banana-checker": "~0.5.0", "grunt-cli": "0.1.13", + "grunt-contrib-clean": "^1.0.0", + "grunt-contrib-concat": "^1.0.1", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-cssmin": "^1.0.1", "grunt-contrib-jshint": "0.11.2", "grunt-contrib-qunit": ">=0.2.1", - "grunt-jscs": "2.1.0", + "grunt-contrib-uglify": "^1.0.1", + "grunt-filerev": "^2.3.1", + "grunt-jscs": "^2.1.0", "grunt-jsonlint": "1.0.4", - "sinon": "~1.17.3", + "grunt-shell": "^1.3.0", + "grunt-usemin": "^3.1.1", "karma-qunit": "0.1.9", + "load-grunt-tasks": "^3.5.0", "qunitjs": "1.23.1", - "grunt-banana-checker": "~0.5.0", - "grunt-contrib-copy": "", - "grunt-contrib-clean": "", - "grunt-usemin": "", - "grunt-filerev": "", - "grunt-contrib-concat": "", - "grunt-contrib-uglify": "", - "grunt-contrib-cssmin": "", - "grunt-contrib-htmlmin": "^1.4.0" + "grunt-contrib-htmlmin": "^1.4.0", + "sinon": "~1.17.3" } } -- To view, visit https://gerrit.wikimedia.org/r/294509 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icd62f69f06ea4cff9ecbc769905373fac2017a4e Gerrit-PatchSet: 6 Gerrit-Project: wikidata/query/gui Gerrit-Branch: master Gerrit-Owner: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> Gerrit-Reviewer: Smalyshev <smalys...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits