diff --git a/.travis.yml b/.travis.yml index dc913ff..f7bfbd2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,12 +52,17 @@ script: - tox -e $TOXENV after_success: - codecov +before_deploy: ./set_version.py deploy: - provider: pypi - user: codingjoe - password: - secure: fEP9K7y0ZF9fRvQEUN4kgPXQEZvi3Cx3ikUebG2UM/2uhcaUQm0+KpgZ2S+lvOTYcBnNgzPzFsVIZMcVcTxwIKuQDEMq9y2eop2hnisb9KXsIm9qPYSzOnRm74VuiOt4hNOZMe0qVBK2cO3vC9NDXuzdI8A0JynJhthfl4t+kFM= + - provider: pypi + distributions: sdist bdist_wheel + user: codingjoe + password: + secure: fEP9K7y0ZF9fRvQEUN4kgPXQEZvi3Cx3ikUebG2UM/2uhcaUQm0+KpgZ2S+lvOTYcBnNgzPzFsVIZMcVcTxwIKuQDEMq9y2eop2hnisb9KXsIm9qPYSzOnRm74VuiOt4hNOZMe0qVBK2cO3vC9NDXuzdI8A0JynJhthfl4t+kFM= + - provider: npm + email: info@johanneshoppe.com + api_key: + secure: PV38cQx9qhEFkpSdytbM72UzIMCfhpjmRJ8dzT+bCAaOIs5rEcyKN+h1r5ranunCxWyuFsMW4A2iW/SCxnKCR/oPAguuwUbT5ogBXlsskqPFWUxuoTHYMrd+zB+SC6+bMgq+o5ul+kJCYtEkWP6cMlIEzKyTLab7m5PsnDXNVnI= on: tags: true - distributions: sdist bdist_wheel repo: applegrew/django-select2 diff --git a/django_select2/static/django_select2/django_select2.js b/django_select2/static/django_select2/django_select2.js index a196067..6c8101a 100644 --- a/django_select2/static/django_select2/django_select2.js +++ b/django_select2/static/django_select2/django_select2.js @@ -1,4 +1,15 @@ -(function ($) { +/* global define, jQuery */ +(function (factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory) + } else if (typeof module === 'object' && module.exports) { + module.exports = factory(require('jquery')) + } else { + // Browser globals + factory(jQuery) + } +}(function ($) { + 'use strict' var init = function ($element, options) { $element.select2(options) } @@ -53,4 +64,6 @@ $(function () { $('.django-select2').djangoSelect2() }) -}(this.jQuery)) + + return $.fn.djangoSelect2 +})) diff --git a/package.json b/package.json new file mode 100644 index 0000000..1a77c97 --- /dev/null +++ b/package.json @@ -0,0 +1,34 @@ +{ + "name": "django-select2", + "version": "0.0.0", + "description": "This is a Django integration of Select2.", + "files": [ + "django_select2/static/**/*" + ], + "main": "django_select2/static/django_select2/django_select2.js", + "directories": { + "doc": "docs", + "test": "tests" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git://github.com/applegrew/django-select2.git" + }, + "keywords": [ + "django", + "select2" + ], + "author": "Johannes Hoppe", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/applegrew/django-select2/issues" + }, + "homepage": "https://github.com/applegrew/django-select2#readme", + "peerDependencies": { + "select2": "*", + "jquery": ">= 1.2" + } +} diff --git a/set_version.py b/set_version.py new file mode 100755 index 0000000..c761734 --- /dev/null +++ b/set_version.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +import json +import os + +def main(): + with open('package.json', 'r+') as f: + data = json.load(f) + f.seek(0) + data['version'] = os.environ['TRAVIS_TAG'] + json.dump(data, f) + f.truncate()