Skip to content

Commit

Permalink
Merge pull request #2550 from koenpunt/generic-package
Browse files Browse the repository at this point in the history
update packaging, now with npm support
  • Loading branch information
pfiller authored Jun 22, 2016
2 parents 7b44637 + 4340f29 commit 0b00300
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ node_modules
.project
public/*.js
public/*.css
public/bower.json
public/*.json
chosen.zip
.sass-cache
.ruby-version
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: false
language: node_js

node_js:
- "0.10"
- "node"

addons:
apt:
Expand All @@ -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:
Expand Down
90 changes: 16 additions & 74 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand All @@ -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']
Expand All @@ -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'
Expand All @@ -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' ]
Expand All @@ -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")
38 changes: 0 additions & 38 deletions bower-publish.sh

This file was deleted.

49 changes: 0 additions & 49 deletions chosen.jquery.json

This file was deleted.

15 changes: 15 additions & 0 deletions package-travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sudo: false

language: node_js

node_js:
- "node"

deploy:
provider: npm
email: chosenjs@getharvest.com
api_key:
secure: jilkDlYp31lPr5AxNTSoC7cgeJv1k+HFyD97RdscUm7Oc45397H//62twQY1w8gUtonjqoncSUe+deElbBs8Zm1RXoX3F3YdcrdhLgmpUFa6Qt2L1ttSJRJ/HOn7NxupwNAHCFiLib5ffFED6FvntHJG/A1693yQeR9lycMsmrQ=
on:
tags: true
repo: harvesthq/chosen-package
87 changes: 41 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@
"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"
},
"scripts": {
"test": "grunt test"
},
"dependencies": {},
"dependencies": {
"jquery": ">=1.4.4"
},
"devDependencies": {
"coffee-script": ">= 1.6",
"grunt": "~0.4.1",
Expand All @@ -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"
}
}
}
Loading

0 comments on commit 0b00300

Please sign in to comment.