From f1e94934c1759eec1124daef00631ce717737b94 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Wed, 24 Feb 2016 02:04:32 +0100 Subject: [PATCH 1/2] update packaging - the packaging tasks are now separated from the build tasks - bower.json and package.json are build into the packaging directory - streamlined generation of json files - add npm support for package write manifests to public directory remove jQuery packaging use chosen-js as npm package name add additional travis configuration for packaging --- .gitignore | 2 +- .travis.yml | 4 +- Gruntfile.coffee | 90 ++++++++------------------------------------ bower-publish.sh | 38 ------------------- chosen.jquery.json | 49 ------------------------ package-travis.yml | 15 ++++++++ package.json | 87 ++++++++++++++++++++---------------------- publish-package.sh | 40 ++++++++++++++++++++ tasks/package.coffee | 63 +++++++++++++++++++++++++++++++ 9 files changed, 178 insertions(+), 210 deletions(-) delete mode 100755 bower-publish.sh delete mode 100644 chosen.jquery.json create mode 100644 package-travis.yml create mode 100755 publish-package.sh create mode 100644 tasks/package.coffee diff --git a/.gitignore b/.gitignore index 4de164c8375..3ba68d04c9d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ node_modules .project public/*.js public/*.css -public/bower.json +public/*.json chosen.zip .sass-cache .ruby-version diff --git a/.travis.yml b/.travis.yml index d33b281ad70..9ac033f0b37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,9 +17,9 @@ before_install: - gem install bundler - bundle install -before_script: grunt build +before_script: grunt build package-npm package-bower -after_success: ./bower-publish.sh +after_success: ./publish-package.sh env: global: diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 91965cd1b2f..2c032e1ded3 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -1,13 +1,9 @@ module.exports = (grunt) -> - require('load-grunt-tasks')(grunt); - - version = -> - grunt.file.readJSON("package.json").version - version_tag = -> - "v#{version()}" + require('load-grunt-tasks')(grunt) grunt.initConfig - pkg: grunt.file.readJSON("package.json") + pkg: grunt.file.readJSON('package.json') + version_tag: 'v<%= pkg.version %>' comments: """ /*! Chosen, a Select Box Enhancer for jQuery and Prototype @@ -22,20 +18,20 @@ This file is generated by `grunt build`, do not edit it by hand. */ \n """ - minified_comments: "/* Chosen #{version_tag()} | (c) 2011-<%= grunt.template.today('yyyy') %> by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */\n" + minified_comments: "/* Chosen <%= version_tag %> | (c) 2011-<%= grunt.template.today('yyyy') %> by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */\n" concat: options: - banner: "<%= comments %>" + banner: '<%= comments %>' jquery: - src: ["public/chosen.jquery.js"] - dest: "public/chosen.jquery.js" + src: ['public/chosen.jquery.js'] + dest: 'public/chosen.jquery.js' proto: - src: ["public/chosen.proto.js"] - dest: "public/chosen.proto.js" + src: ['public/chosen.proto.js'] + dest: 'public/chosen.proto.js' css: - src: ["public/chosen.css"] - dest: "public/chosen.css" + src: ['public/chosen.css'] + dest: 'public/chosen.css' coffee: options: @@ -51,7 +47,7 @@ This file is generated by `grunt build`, do not edit it by hand. options: mangle: except: ['jQuery', 'AbstractChosen', 'Chosen', 'SelectParser'] - banner: "<%= minified_comments %>" + banner: '<%= minified_comments %>' minified_chosen_js: files: 'public/chosen.jquery.min.js': ['public/chosen.jquery.js'] @@ -66,7 +62,7 @@ This file is generated by `grunt build`, do not edit it by hand. cssmin: minified_chosen_css: options: - banner: "<%= minified_comments %>" + banner: '<%= minified_comments %>' keepSpecialComments: 0 src: 'public/chosen.css' dest: 'public/chosen.min.css' @@ -76,24 +72,6 @@ This file is generated by `grunt build`, do not edit it by hand. files: ['coffee/**/*.coffee', 'sass/*.scss'] tasks: ['build'] - dom_munger: - latest_version: - src: ['public/index.html', 'public/index.proto.html', 'public/options.html'] - options: - callback: ($) -> - $("#latest-version").text(version_tag()) - zip: - chosen: - cwd: 'public/' - src: ['public/**/*'] - dest: "chosen_#{version_tag()}.zip" - - 'gh-pages': - options: - base: 'public', - message: "Updated to new Chosen version #{version()}" - src: ['**'] - jasmine: jquery: src: [ 'public/chosen.jquery.js' ] @@ -109,46 +87,10 @@ This file is generated by `grunt build`, do not edit it by hand. ] specs: 'spec/public/proto_specs.js' + grunt.loadTasks 'tasks' + grunt.registerTask 'default', ['build'] - grunt.registerTask 'build', ['coffee', 'compass', 'concat', 'uglify', 'cssmin', 'package-bower'] - grunt.registerTask 'prep-release', ['build', 'dom_munger:latest_version', 'zip:chosen','package-jquery'] + grunt.registerTask 'build', ['coffee', 'compass', 'concat', 'uglify', 'cssmin'] grunt.registerTask 'test', ['coffee', 'jasmine'] - grunt.registerTask 'publish-release', ['gh-pages'] - - grunt.registerTask 'package-jquery', 'Generate a jquery.json manifest file from package.json', () -> - src = "package.json" - dest = "chosen.jquery.json" - pkg = grunt.file.readJSON(src) - json1 = - "name": pkg.name - "description": pkg.description - "version": version() - "licenses": pkg.licenses - json2 = pkg.jqueryJSON - json1[key] = json2[key] for key of json2 - json1.author.name = pkg.author - grunt.file.write('chosen.jquery.json', JSON.stringify(json1, null, 2) + "\n") - - grunt.registerTask 'package-bower', 'Generate a bower.json manifest file from package.json', () -> - pkg = grunt.file.readJSON("package.json") - bowerjson = pkg.bowerJSON - jqueryjson = pkg.jqueryJSON - - bower = - "name": pkg.name - "description": pkg.description - "main": bowerjson.main - "license": pkg.licenses - "ignore": [] - "keywords": jqueryjson.keywords - "authors": jqueryjson.maintainers - "homepage": jqueryjson.homepage - "repository": pkg.repository - "dependencies": jqueryjson.dependencies - "devDependencies": [] - - grunt.file.write("public/bower.json", JSON.stringify(bower, null, 2) + "\n") - grunt.registerTask 'cleanup-bower', 'Delete generated bower.json file', () -> - grunt.file.delete("public/bower.json") diff --git a/bower-publish.sh b/bower-publish.sh deleted file mode 100755 index a112d846544..00000000000 --- a/bower-publish.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -set -e - -CURRENT_BRANCH=`git name-rev --name-only HEAD` - -if [ $CURRENT_BRANCH != 'master' ] ; then - echo "Build not on master. Skipped bower-chosen release" - exit 0 -fi - -CHOSEN_VERSION=`git tag --sort=v:refname | tail -1` - -git config --global user.email "notmyemail@bower-chosen.lol" -git config --global user.name "bower-chosen" - -git clone https://pfiller:${GH_TOKEN}@github.com/harvesthq/bower-chosen.git -rm -rf bower-chosen/* -cp public/bower.json public/*.png public/chosen.jquery.js public/chosen.css bower-chosen/ -cd bower-chosen - -LATEST_VERSION=`git tag --sort=v:refname | tail -1` - -if [ "$LATEST_VERSION" = "$CHOSEN_VERSION" ] ; then - echo "No Chosen version change. Skipped tagging" -else - echo "Chosen version changed. Tagging version ${CHOSEN_VERSION}\n" - git tag -a "${CHOSEN_VERSION}" -m "Version ${CHOSEN_VERSION}" -fi - -git remote set-url origin https://pfiller:${GH_TOKEN}@github.com/harvesthq/bower-chosen.git - -git add -A -git commit -m "Chosen build to bower-chosen" -git push origin master -git push origin --tags - -echo "Chosen published to harvesthq/bower-chosen" diff --git a/chosen.jquery.json b/chosen.jquery.json deleted file mode 100644 index f008e2f0bba..00000000000 --- a/chosen.jquery.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "chosen", - "description": "Chosen is a JavaScript plugin that makes select boxes user-friendly. It is currently available in both jQuery and Prototype flavors.", - "version": "1.5.1", - "licenses": [ - { - "type": "MIT", - "url": "https://github.com/harvesthq/chosen/blob/master/LICENSE.md" - } - ], - "title": "Chosen", - "keywords": [ - "select", - "multiselect", - "dropdown", - "form", - "input", - "ui" - ], - "author": { - "url": "http://getharvest.com", - "name": "harvest" - }, - "maintainers": [ - { - "name": "Patrick Filler", - "url": "https://github.com/pfiller" - }, - { - "name": "Christophe Coevoet", - "url": "https://github.com/stof" - }, - { - "name": "Ken Earley", - "url": "https://github.com/kenearley" - }, - { - "name": "Koen Punt", - "url": "https://github.com/koenpunt" - } - ], - "download": "https://github.com/harvesthq/chosen/releases", - "homepage": "http://harvesthq.github.io/chosen/", - "docs": "http://harvesthq.github.io/chosen/", - "bugs": "https://github.com/harvesthq/chosen/issues", - "dependencies": { - "jquery": ">=1.4.4" - } -} diff --git a/package-travis.yml b/package-travis.yml new file mode 100644 index 00000000000..bc73421dd95 --- /dev/null +++ b/package-travis.yml @@ -0,0 +1,15 @@ +sudo: false + +language: node_js + +node_js: + - "0.10" + +deploy: + provider: npm + email: chosenjs@getharvest.com + api_key: + secure: jilkDlYp31lPr5AxNTSoC7cgeJv1k+HFyD97RdscUm7Oc45397H//62twQY1w8gUtonjqoncSUe+deElbBs8Zm1RXoX3F3YdcrdhLgmpUFa6Qt2L1ttSJRJ/HOn7NxupwNAHCFiLib5ffFED6FvntHJG/A1693yQeR9lycMsmrQ= + on: + tags: true + repo: harvesthq/chosen-package diff --git a/package.json b/package.json index 3c1cb252003..aefabbb1bef 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,17 @@ "name": "chosen", "version": "1.5.1", "description": "Chosen is a JavaScript plugin that makes select boxes user-friendly. It is currently available in both jQuery and Prototype flavors.", + "keywords": [ + "select", + "multiselect", + "dropdown", + "form", + "input", + "ui" + ], "repository": { "type": "git", - "url": "https://github.com/harvesthq/chosen" + "url": "https://github.com/harvesthq/chosen.git" }, "engines": { "node": ">=0.4.0" @@ -13,7 +21,9 @@ "scripts": { "test": "grunt test" }, - "dependencies": {}, + "dependencies": { + "jquery": ">=1.4.4" + }, "devDependencies": { "coffee-script": ">= 1.6", "grunt": "~0.4.1", @@ -29,55 +39,40 @@ "grunt-zip": "~0.9.2", "load-grunt-tasks": "^3.0.0" }, - "licenses": [ + "contributors": [ { - "type": "MIT", - "url": "https://github.com/harvesthq/chosen/blob/master/LICENSE.md" + "name": "Patrick Filler", + "url": "https://github.com/pfiller" + }, + { + "name": "Christophe Coevoet", + "url": "https://github.com/stof" + }, + { + "name": "Ken Earley", + "url": "https://github.com/kenearley" + }, + { + "name": "Koen Punt", + "url": "https://github.com/koenpunt" } ], - "bowerJSON":{ - "main": [ + "license": "MIT", + "homepage": "https://harvesthq.github.io/chosen/", + "bugs": "https://github.com/harvesthq/chosen/issues", + "_extra": { + "title": "Chosen", + "license": { + "type": "MIT", + "url": "https://github.com/harvesthq/chosen/blob/master/LICENSE.md" + }, + "links": { + "download": "https://github.com/harvesthq/chosen/releases", + "docs": "https://harvesthq.github.io/chosen/" + }, + "files": [ "chosen.jquery.js", "chosen.css" ] - }, - "jqueryJSON": { - "title": "Chosen", - "keywords": [ - "select", - "multiselect", - "dropdown", - "form", - "input", - "ui" - ], - "author": { - "url": "http://getharvest.com" - }, - "maintainers": [ - { - "name": "Patrick Filler", - "url": "https://github.com/pfiller" - }, - { - "name": "Christophe Coevoet", - "url": "https://github.com/stof" - }, - { - "name": "Ken Earley", - "url": "https://github.com/kenearley" - }, - { - "name": "Koen Punt", - "url": "https://github.com/koenpunt" - } - ], - "download": "https://github.com/harvesthq/chosen/releases", - "homepage": "http://harvesthq.github.io/chosen/", - "docs": "http://harvesthq.github.io/chosen/", - "bugs": "https://github.com/harvesthq/chosen/issues", - "dependencies": { - "jquery": ">=1.4.4" - } } } diff --git a/publish-package.sh b/publish-package.sh new file mode 100755 index 00000000000..e51676e8a4c --- /dev/null +++ b/publish-package.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +set -e + +CURRENT_BRANCH=`git name-rev --name-only HEAD` + +if [ $CURRENT_BRANCH != 'master' ] ; then + echo "Build not on master. Skipped chosen-package release" + exit 0 +fi + +CHOSEN_VERSION=`git tag --sort=v:refname | tail -1` +GITHUB_URL=https://pfiller:${GH_TOKEN}@github.com/harvesthq/chosen-package.git + +git clone $GITHUB_URL +rm -rf chosen-package/* +cp README.md public/*.json public/*.png public/chosen.jquery.js public/chosen.css chosen-package/ +cp package-travis.yml chosen-package/.travis.yml +cd chosen-package + +git config user.email "chosen@getharvest.com" +git config user.name "chosen-package" + +LATEST_VERSION=`git tag --sort=v:refname | tail -1` + +if [ "$LATEST_VERSION" = "$CHOSEN_VERSION" ] ; then + echo "No Chosen version change. Skipped tagging" +else + echo "Chosen version changed. Tagging version ${CHOSEN_VERSION}\n" + git tag -a "${CHOSEN_VERSION}" -m "Version ${CHOSEN_VERSION}" +fi + +git remote set-url origin $GITHUB_URL + +git add -A +git commit -m "Chosen build to chosen-package" +git push origin master +git push origin --tags + +echo "Chosen published to harvesthq/chosen-package" diff --git a/tasks/package.coffee b/tasks/package.coffee new file mode 100644 index 00000000000..8578e3d7e29 --- /dev/null +++ b/tasks/package.coffee @@ -0,0 +1,63 @@ +### +This file contains tasks only necessary for packaging and publishing Chosen +### +module.exports = (grunt) -> + + grunt.config 'dom_munger', + latest_version: + src: ['public/index.html', 'public/index.proto.html', 'public/options.html'] + options: + callback: ($) -> + $('#latest-version').text(grunt.config.get('version_tag')) + + grunt.config 'zip', + chosen: + cwd: 'public/' + src: ['public/**/*'] + dest: 'chosen_<%= version_tag %>.zip' + + grunt.config 'gh-pages', + options: + base: 'public', + message: 'Updated to new Chosen version <%= pkg.version %>' + src: ['**'] + + grunt.registerTask 'package-npm', 'Generate npm manifest', () -> + pkg = grunt.config.get('pkg') + + json = + name: "#{pkg.name}-js" + version: pkg.version + description: pkg.description + keywords: pkg.keywords + homepage: pkg.homepage + bugs: pkg.bugs + license: pkg.license + contributors: pkg.contributors + dependencies: pkg.dependencies + files: pkg._extra.files + main: pkg._extra.files[0] + repository: pkg.repository + + grunt.file.write('public/package.json', JSON.stringify(json, null, 2) + "\n") + + grunt.registerTask 'package-bower', 'Generate bower manifest', () -> + pkg = grunt.config.get('pkg') + extra = pkg._extra + + json = + name: pkg.name + description: pkg.description + keywords: pkg.keywords + homepage: pkg.homepage + license: extra.license.url + authors: pkg.contributors + dependencies: pkg.dependencies + main: extra.files + ignore: [] + repository: pkg.repository + + grunt.file.write('public/bower.json', JSON.stringify(json, null, 2) + "\n") + + grunt.registerTask 'prep-release', ['build', 'dom_munger:latest_version', 'zip:chosen', 'package-npm', 'package-bower'] + grunt.registerTask 'publish-release', ['gh-pages'] From 4340f2936017e5d397af52b521356f019ac1927e Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Wed, 22 Jun 2016 22:32:57 +0200 Subject: [PATCH 2/2] use latest node version on travis --- .travis.yml | 2 +- package-travis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9ac033f0b37..5d860284f67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: false language: node_js node_js: - - "0.10" + - "node" addons: apt: diff --git a/package-travis.yml b/package-travis.yml index bc73421dd95..74c399b11b3 100644 --- a/package-travis.yml +++ b/package-travis.yml @@ -3,7 +3,7 @@ sudo: false language: node_js node_js: - - "0.10" + - "node" deploy: provider: npm