diff --git a/.eslintignore b/.eslintignore index 809a96a..cb9e0c2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ node_modules/ lib/ +amd/ karma.conf.js diff --git a/.gitignore b/.gitignore index 4e74526..3daf837 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,7 @@ -# Created by http://www.gitignore.io - -### Node ### -# Logs -logs -*.log - -# Runtime data -pids -*.pid -*.seed - -# JSX -.module-cache - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directory -# Commenting this out is preferred by some people, see -# https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git +*~ +.DS_Store +npm-debug.log* node_modules -bower_components - -# Users Environment Variables -.lock-wscript +amd +lib +tmp-bower-repo diff --git a/bower.json b/bower.json deleted file mode 100644 index ed84525..0000000 --- a/bower.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "react-router-bootstrap", - "version": "0.17.1", - "description": "react-router and react-bootstrap compatible components", - "main": "lib/ReactRouterBootstrap.js", - "homepage": "https://github.com/react-bootstrap/react-router-bootstrap", - "author": { - "name": "Matt Smith", - "email": "mtscout6@gmail.com" - }, - "license": "Apache-2.0", - "repository": { - "type": "git", - "url": "git://github.com/react-bootstrap/react-router-bootstrap.git" - }, - "dependencies": { - "react-bootstrap": ">=0.22.4", - "react-router": ">=0.13.1" - }, - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "tests", - "src", - "CONTRIBUTING.md", - "karma.conf.js", - "package.json", - "webpack.config.js", - "webpack.test.config.js" - ] -} diff --git a/bower.template.json b/bower.template.json new file mode 100644 index 0000000..4c35de5 --- /dev/null +++ b/bower.template.json @@ -0,0 +1,25 @@ +{ + "name": "<%= pkg.name %>", + "version": "<%= pkg.version %>", + "homepage": "<%= pkg.homepage %>", + "author": <%= JSON.stringify(pkg.author) %>, + "license": "<%= pkg.license %>", + "main": "lib/ReactRouterBootstrap.js", + "bugs": <%= JSON.stringify(pkg.bugs) %>, + "keywords": [ + <%= _.map(pkg.keywords, function(keyword) { return '"' + keyword + '"' }).join(',')%> + ], + "dependencies": <%= JSON.stringify(pkg.peerDependencies) %>, + "ignore": [ + "**/.*", + "tests", + "src", + "CONTRIBUTING.md", + "karma.conf.js", + "package.json", + "webpack", + "scripts", + "webpack.config.babel.js", + "webpack.test.config.babel.js" + ] +} diff --git a/lib/ButtonLink.js b/lib/ButtonLink.js deleted file mode 100644 index d4027ec..0000000 --- a/lib/ButtonLink.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _reactBootstrapLibButton = require('react-bootstrap/lib/Button'); - -var _reactBootstrapLibButton2 = _interopRequireDefault(_reactBootstrapLibButton); - -var _LinkMixin = require('./LinkMixin'); - -var _LinkMixin2 = _interopRequireDefault(_LinkMixin); - -var ButtonLink = _react2['default'].createClass({ - displayName: 'ButtonLink', - - mixins: [_LinkMixin2['default']], - - render: function render() { - return _react2['default'].createElement( - _reactBootstrapLibButton2['default'], - _extends({}, this.getLinkProps(), { ref: 'button' }), - this.props.children - ); - } -}); - -exports['default'] = ButtonLink; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/LinkMixin.js b/lib/LinkMixin.js deleted file mode 100644 index baf8e20..0000000 --- a/lib/LinkMixin.js +++ /dev/null @@ -1,96 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -function isLeftClickEvent(event) { - return event.button === 0; -} - -function isModifiedEvent(event) { - return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey); -} - -exports['default'] = { - propTypes: { - active: _react2['default'].PropTypes.bool, - activeClassName: _react2['default'].PropTypes.string.isRequired, - disabled: _react2['default'].PropTypes.bool, - to: _react2['default'].PropTypes.string.isRequired, - params: _react2['default'].PropTypes.object, - query: _react2['default'].PropTypes.object, - onClick: _react2['default'].PropTypes.func - }, - contextTypes: { - router: _react2['default'].PropTypes.func.isRequired - }, - - getDefaultProps: function getDefaultProps() { - return { - activeClassName: 'active' - }; - }, - - /** - * Returns props except those used by this Mixin - * Gets "active" from router if needed. - * Gets the value of the "href" attribute to use on the DOM element. - * Sets "onClick" to "handleRouteTo". - */ - getLinkProps: function getLinkProps() { - var _props = this.props; - var to = _props.to; - var params = _props.params; - var query = _props.query; - - var props = _objectWithoutProperties(_props, ['to', 'params', 'query']); - - if (this.props.active === undefined) { - props.active = this.context.router.isActive(to, params, query); - } - - props.href = this.context.router.makeHref(to, params, query); - - props.onClick = this.handleRouteTo; - - return props; - }, - - handleRouteTo: function handleRouteTo(event) { - var allowTransition = true; - var clickResult = undefined; - - if (this.props.disabled) { - event.preventDefault(); - return; - } - - if (this.props.onClick) { - clickResult = this.props.onClick(event); - } - - if (isModifiedEvent(event) || !isLeftClickEvent(event)) { - return; - } - - if (clickResult === false || event.defaultPrevented === true) { - allowTransition = false; - } - - event.preventDefault(); - - if (allowTransition) { - this.context.router.transitionTo(this.props.to, this.props.params, this.props.query); - } - } -}; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/ListGroupItemLink.js b/lib/ListGroupItemLink.js deleted file mode 100644 index e5ebab5..0000000 --- a/lib/ListGroupItemLink.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _reactBootstrapLibListGroupItem = require('react-bootstrap/lib/ListGroupItem'); - -var _reactBootstrapLibListGroupItem2 = _interopRequireDefault(_reactBootstrapLibListGroupItem); - -var _LinkMixin = require('./LinkMixin'); - -var _LinkMixin2 = _interopRequireDefault(_LinkMixin); - -var LinkGroupItemLink = _react2['default'].createClass({ - displayName: 'LinkGroupItemLink', - - mixins: [_LinkMixin2['default']], - - render: function render() { - return _react2['default'].createElement( - _reactBootstrapLibListGroupItem2['default'], - _extends({}, this.getLinkProps(), { ref: 'listGroupItem' }), - this.props.children - ); - } -}); - -exports['default'] = LinkGroupItemLink; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/MenuItemLink.js b/lib/MenuItemLink.js deleted file mode 100644 index bc836e7..0000000 --- a/lib/MenuItemLink.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _reactBootstrapLibMenuItem = require('react-bootstrap/lib/MenuItem'); - -var _reactBootstrapLibMenuItem2 = _interopRequireDefault(_reactBootstrapLibMenuItem); - -var _LinkMixin = require('./LinkMixin'); - -var _LinkMixin2 = _interopRequireDefault(_LinkMixin); - -var MenuItemLink = _react2['default'].createClass({ - displayName: 'MenuItemLink', - - mixins: [_LinkMixin2['default']], - - render: function render() { - var props = this.getLinkProps(); - delete props.onSelect; // this is done on the copy of this.props - - return _react2['default'].createElement( - _reactBootstrapLibMenuItem2['default'], - _extends({}, props, { ref: 'menuItem' }), - this.props.children - ); - } -}); - -exports['default'] = MenuItemLink; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/NavItemLink.js b/lib/NavItemLink.js deleted file mode 100644 index 21879c2..0000000 --- a/lib/NavItemLink.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _reactBootstrapLibNavItem = require('react-bootstrap/lib/NavItem'); - -var _reactBootstrapLibNavItem2 = _interopRequireDefault(_reactBootstrapLibNavItem); - -var _LinkMixin = require('./LinkMixin'); - -var _LinkMixin2 = _interopRequireDefault(_LinkMixin); - -var NavItemLink = _react2['default'].createClass({ - displayName: 'NavItemLink', - - mixins: [_LinkMixin2['default']], - - render: function render() { - return _react2['default'].createElement( - _reactBootstrapLibNavItem2['default'], - _extends({}, this.getLinkProps(), { ref: 'navItem' }), - this.props.children - ); - } -}); - -exports['default'] = NavItemLink; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/ReactRouterBootstrap.js b/lib/ReactRouterBootstrap.js deleted file mode 100644 index 36bd90e..0000000 --- a/lib/ReactRouterBootstrap.js +++ /dev/null @@ -1,428 +0,0 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("react"), require("react-bootstrap")); - else if(typeof define === 'function' && define.amd) - define(["react", "react-bootstrap"], factory); - else if(typeof exports === 'object') - exports["ReactRouterBootstrap"] = factory(require("react"), require("react-bootstrap")); - else - root["ReactRouterBootstrap"] = factory(root["React"], root["ReactBootstrap"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__) { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; - -/******/ // The require function -/******/ function __webpack_require__(moduleId) { - -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; - -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; - -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - -/******/ // Flag the module as loaded -/******/ module.loaded = true; - -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } - - -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; - -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; - -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; - -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _ButtonLink = __webpack_require__(5); - - var _ButtonLink2 = _interopRequireDefault(_ButtonLink); - - var _ListGroupItemLink = __webpack_require__(6); - - var _ListGroupItemLink2 = _interopRequireDefault(_ListGroupItemLink); - - var _MenuItemLink = __webpack_require__(7); - - var _MenuItemLink2 = _interopRequireDefault(_MenuItemLink); - - var _NavItemLink = __webpack_require__(1); - - var _NavItemLink2 = _interopRequireDefault(_NavItemLink); - - var _RouterModalTrigger = __webpack_require__(8); - - var _RouterModalTrigger2 = _interopRequireDefault(_RouterModalTrigger); - - var _RouterOverlayTrigger = __webpack_require__(9); - - var _RouterOverlayTrigger2 = _interopRequireDefault(_RouterOverlayTrigger); - - exports['default'] = { - ButtonLink: _ButtonLink2['default'], - ListGroupItemLink: _ListGroupItemLink2['default'], - MenuItemLink: _MenuItemLink2['default'], - NavItemLink: _NavItemLink2['default'], - RouterModalTrigger: _RouterModalTrigger2['default'], - RouterOverlayTrigger: _RouterOverlayTrigger2['default'] - }; - module.exports = exports['default']; - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _reactBootstrap = __webpack_require__(3); - - var _LinkMixin = __webpack_require__(4); - - var _LinkMixin2 = _interopRequireDefault(_LinkMixin); - - var NavItemLink = _react2['default'].createClass({ - displayName: 'NavItemLink', - - mixins: [_LinkMixin2['default']], - - render: function render() { - return _react2['default'].createElement( - _reactBootstrap.NavItem, - _extends({}, this.getLinkProps(), { ref: 'navItem' }), - this.props.children - ); - } - }); - - exports['default'] = NavItemLink; - module.exports = exports['default']; - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_2__; - -/***/ }, -/* 3 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_3__; - -/***/ }, -/* 4 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - function isLeftClickEvent(event) { - return event.button === 0; - } - - function isModifiedEvent(event) { - return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey); - } - - exports['default'] = { - propTypes: { - active: _react2['default'].PropTypes.bool, - activeClassName: _react2['default'].PropTypes.string.isRequired, - disabled: _react2['default'].PropTypes.bool, - to: _react2['default'].PropTypes.string.isRequired, - params: _react2['default'].PropTypes.object, - query: _react2['default'].PropTypes.object, - onClick: _react2['default'].PropTypes.func - }, - contextTypes: { - router: _react2['default'].PropTypes.func.isRequired - }, - - getDefaultProps: function getDefaultProps() { - return { - activeClassName: 'active' - }; - }, - - /** - * Returns props except those used by this Mixin - * Gets "active" from router if needed. - * Gets the value of the "href" attribute to use on the DOM element. - * Sets "onClick" to "handleRouteTo". - */ - getLinkProps: function getLinkProps() { - var _props = this.props; - var to = _props.to; - var params = _props.params; - var query = _props.query; - - var props = _objectWithoutProperties(_props, ['to', 'params', 'query']); - - if (this.props.active === undefined) { - props.active = this.context.router.isActive(to, params, query); - } - - props.href = this.context.router.makeHref(to, params, query); - - props.onClick = this.handleRouteTo; - - return props; - }, - - handleRouteTo: function handleRouteTo(event) { - var allowTransition = true; - var clickResult = undefined; - - if (this.props.disabled) { - event.preventDefault(); - return; - } - - if (this.props.onClick) { - clickResult = this.props.onClick(event); - } - - if (isModifiedEvent(event) || !isLeftClickEvent(event)) { - return; - } - - if (clickResult === false || event.defaultPrevented === true) { - allowTransition = false; - } - - event.preventDefault(); - - if (allowTransition) { - this.context.router.transitionTo(this.props.to, this.props.params, this.props.query); - } - } - }; - module.exports = exports['default']; - -/***/ }, -/* 5 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _reactBootstrap = __webpack_require__(3); - - var _LinkMixin = __webpack_require__(4); - - var _LinkMixin2 = _interopRequireDefault(_LinkMixin); - - var ButtonLink = _react2['default'].createClass({ - displayName: 'ButtonLink', - - mixins: [_LinkMixin2['default']], - - render: function render() { - return _react2['default'].createElement( - _reactBootstrap.Button, - _extends({}, this.getLinkProps(), { ref: 'button' }), - this.props.children - ); - } - }); - - exports['default'] = ButtonLink; - module.exports = exports['default']; - -/***/ }, -/* 6 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _reactBootstrap = __webpack_require__(3); - - var _LinkMixin = __webpack_require__(4); - - var _LinkMixin2 = _interopRequireDefault(_LinkMixin); - - var LinkGroupItemLink = _react2['default'].createClass({ - displayName: 'LinkGroupItemLink', - - mixins: [_LinkMixin2['default']], - - render: function render() { - return _react2['default'].createElement( - _reactBootstrap.ListGroupItem, - _extends({}, this.getLinkProps(), { ref: 'listGroupItem' }), - this.props.children - ); - } - }); - - exports['default'] = LinkGroupItemLink; - module.exports = exports['default']; - -/***/ }, -/* 7 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _reactBootstrap = __webpack_require__(3); - - var _LinkMixin = __webpack_require__(4); - - var _LinkMixin2 = _interopRequireDefault(_LinkMixin); - - var MenuItemLink = _react2['default'].createClass({ - displayName: 'MenuItemLink', - - mixins: [_LinkMixin2['default']], - - render: function render() { - var props = this.getLinkProps(); - delete props.onSelect; // this is done on the copy of this.props - - return _react2['default'].createElement( - _reactBootstrap.MenuItem, - _extends({}, props, { ref: 'menuItem' }), - this.props.children - ); - } - }); - - exports['default'] = MenuItemLink; - module.exports = exports['default']; - -/***/ }, -/* 8 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _reactBootstrap = __webpack_require__(3); - - exports['default'] = _reactBootstrap.ModalTrigger.withContext({ - router: _react2['default'].PropTypes.func - }); - module.exports = exports['default']; - -/***/ }, -/* 9 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, '__esModule', { - value: true - }); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _reactBootstrap = __webpack_require__(3); - - exports['default'] = _reactBootstrap.OverlayTrigger.withContext({ - router: _react2['default'].PropTypes.func - }); - module.exports = exports['default']; - -/***/ } -/******/ ]) -}); -; \ No newline at end of file diff --git a/lib/ReactRouterBootstrap.min.js b/lib/ReactRouterBootstrap.min.js deleted file mode 100644 index 5f08cdf..0000000 --- a/lib/ReactRouterBootstrap.min.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-bootstrap")):"function"==typeof define&&define.amd?define(["react","react-bootstrap"],t):"object"==typeof exports?exports.ReactRouterBootstrap=t(require("react"),require("react-bootstrap")):e.ReactRouterBootstrap=t(e.React,e.ReactBootstrap)}(this,function(e,t){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var n=r(5),u=o(n),a=r(6),s=o(a),i=r(7),l=o(i),f=r(1),p=o(f),d=r(8),c=o(d),v=r(9),y=o(v);t["default"]={ButtonLink:u["default"],ListGroupItemLink:s["default"],MenuItemLink:l["default"],NavItemLink:p["default"],RouterModalTrigger:c["default"],RouterOverlayTrigger:y["default"]},e.exports=t["default"]},function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r}function u(e){return 0===e.button}function a(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}Object.defineProperty(t,"__esModule",{value:!0});var s=r(2),i=o(s);t["default"]={propTypes:{active:i["default"].PropTypes.bool,activeClassName:i["default"].PropTypes.string.isRequired,disabled:i["default"].PropTypes.bool,to:i["default"].PropTypes.string.isRequired,params:i["default"].PropTypes.object,query:i["default"].PropTypes.object,onClick:i["default"].PropTypes.func},contextTypes:{router:i["default"].PropTypes.func.isRequired},getDefaultProps:function(){return{activeClassName:"active"}},getLinkProps:function(){var e=this.props,t=e.to,r=e.params,o=e.query,u=n(e,["to","params","query"]);return void 0===this.props.active&&(u.active=this.context.router.isActive(t,r,o)),u.href=this.context.router.makeHref(t,r,o),u.onClick=this.handleRouteTo,u},handleRouteTo:function(e){var t=!0,r=void 0;return this.props.disabled?void e.preventDefault():(this.props.onClick&&(r=this.props.onClick(e)),void(!a(e)&&u(e)&&((r===!1||e.defaultPrevented===!0)&&(t=!1),e.preventDefault(),t&&this.context.router.transitionTo(this.props.to,this.props.params,this.props.query))))}},e.exports=t["default"]},function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }\n\t\n\tvar _react = __webpack_require__(2);\n\t\n\tvar _react2 = _interopRequireDefault(_react);\n\t\n\tfunction isLeftClickEvent(event) {\n\t return event.button === 0;\n\t}\n\t\n\tfunction isModifiedEvent(event) {\n\t return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);\n\t}\n\t\n\texports['default'] = {\n\t propTypes: {\n\t active: _react2['default'].PropTypes.bool,\n\t activeClassName: _react2['default'].PropTypes.string.isRequired,\n\t disabled: _react2['default'].PropTypes.bool,\n\t to: _react2['default'].PropTypes.string.isRequired,\n\t params: _react2['default'].PropTypes.object,\n\t query: _react2['default'].PropTypes.object,\n\t onClick: _react2['default'].PropTypes.func\n\t },\n\t contextTypes: {\n\t router: _react2['default'].PropTypes.func.isRequired\n\t },\n\t\n\t getDefaultProps: function getDefaultProps() {\n\t return {\n\t activeClassName: 'active'\n\t };\n\t },\n\t\n\t /**\n\t * Returns props except those used by this Mixin\n\t * Gets \"active\" from router if needed.\n\t * Gets the value of the \"href\" attribute to use on the DOM element.\n\t * Sets \"onClick\" to \"handleRouteTo\".\n\t */\n\t getLinkProps: function getLinkProps() {\n\t var _props = this.props;\n\t var to = _props.to;\n\t var params = _props.params;\n\t var query = _props.query;\n\t\n\t var props = _objectWithoutProperties(_props, ['to', 'params', 'query']);\n\t\n\t if (this.props.active === undefined) {\n\t props.active = this.context.router.isActive(to, params, query);\n\t }\n\t\n\t props.href = this.context.router.makeHref(to, params, query);\n\t\n\t props.onClick = this.handleRouteTo;\n\t\n\t return props;\n\t },\n\t\n\t handleRouteTo: function handleRouteTo(event) {\n\t var allowTransition = true;\n\t var clickResult = undefined;\n\t\n\t if (this.props.disabled) {\n\t event.preventDefault();\n\t return;\n\t }\n\t\n\t if (this.props.onClick) {\n\t clickResult = this.props.onClick(event);\n\t }\n\t\n\t if (isModifiedEvent(event) || !isLeftClickEvent(event)) {\n\t return;\n\t }\n\t\n\t if (clickResult === false || event.defaultPrevented === true) {\n\t allowTransition = false;\n\t }\n\t\n\t event.preventDefault();\n\t\n\t if (allowTransition) {\n\t this.context.router.transitionTo(this.props.to, this.props.params, this.props.query);\n\t }\n\t }\n\t};\n\tmodule.exports = exports['default'];\n\n/***/ },\n/* 5 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, '__esModule', {\n\t value: true\n\t});\n\t\n\tvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\t\n\tvar _react = __webpack_require__(2);\n\t\n\tvar _react2 = _interopRequireDefault(_react);\n\t\n\tvar _reactBootstrap = __webpack_require__(3);\n\t\n\tvar _LinkMixin = __webpack_require__(4);\n\t\n\tvar _LinkMixin2 = _interopRequireDefault(_LinkMixin);\n\t\n\tvar ButtonLink = _react2['default'].createClass({\n\t displayName: 'ButtonLink',\n\t\n\t mixins: [_LinkMixin2['default']],\n\t\n\t render: function render() {\n\t return _react2['default'].createElement(\n\t _reactBootstrap.Button,\n\t _extends({}, this.getLinkProps(), { ref: 'button' }),\n\t this.props.children\n\t );\n\t }\n\t});\n\t\n\texports['default'] = ButtonLink;\n\tmodule.exports = exports['default'];\n\n/***/ },\n/* 6 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, '__esModule', {\n\t value: true\n\t});\n\t\n\tvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\t\n\tvar _react = __webpack_require__(2);\n\t\n\tvar _react2 = _interopRequireDefault(_react);\n\t\n\tvar _reactBootstrap = __webpack_require__(3);\n\t\n\tvar _LinkMixin = __webpack_require__(4);\n\t\n\tvar _LinkMixin2 = _interopRequireDefault(_LinkMixin);\n\t\n\tvar LinkGroupItemLink = _react2['default'].createClass({\n\t displayName: 'LinkGroupItemLink',\n\t\n\t mixins: [_LinkMixin2['default']],\n\t\n\t render: function render() {\n\t return _react2['default'].createElement(\n\t _reactBootstrap.ListGroupItem,\n\t _extends({}, this.getLinkProps(), { ref: 'listGroupItem' }),\n\t this.props.children\n\t );\n\t }\n\t});\n\t\n\texports['default'] = LinkGroupItemLink;\n\tmodule.exports = exports['default'];\n\n/***/ },\n/* 7 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, '__esModule', {\n\t value: true\n\t});\n\t\n\tvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\t\n\tvar _react = __webpack_require__(2);\n\t\n\tvar _react2 = _interopRequireDefault(_react);\n\t\n\tvar _reactBootstrap = __webpack_require__(3);\n\t\n\tvar _LinkMixin = __webpack_require__(4);\n\t\n\tvar _LinkMixin2 = _interopRequireDefault(_LinkMixin);\n\t\n\tvar MenuItemLink = _react2['default'].createClass({\n\t displayName: 'MenuItemLink',\n\t\n\t mixins: [_LinkMixin2['default']],\n\t\n\t render: function render() {\n\t var props = this.getLinkProps();\n\t delete props.onSelect; // this is done on the copy of this.props\n\t\n\t return _react2['default'].createElement(\n\t _reactBootstrap.MenuItem,\n\t _extends({}, props, { ref: 'menuItem' }),\n\t this.props.children\n\t );\n\t }\n\t});\n\t\n\texports['default'] = MenuItemLink;\n\tmodule.exports = exports['default'];\n\n/***/ },\n/* 8 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, '__esModule', {\n\t value: true\n\t});\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\t\n\tvar _react = __webpack_require__(2);\n\t\n\tvar _react2 = _interopRequireDefault(_react);\n\t\n\tvar _reactBootstrap = __webpack_require__(3);\n\t\n\texports['default'] = _reactBootstrap.ModalTrigger.withContext({\n\t router: _react2['default'].PropTypes.func\n\t});\n\tmodule.exports = exports['default'];\n\n/***/ },\n/* 9 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, '__esModule', {\n\t value: true\n\t});\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }\n\t\n\tvar _react = __webpack_require__(2);\n\t\n\tvar _react2 = _interopRequireDefault(_react);\n\t\n\tvar _reactBootstrap = __webpack_require__(3);\n\t\n\texports['default'] = _reactBootstrap.OverlayTrigger.withContext({\n\t router: _react2['default'].PropTypes.func\n\t});\n\tmodule.exports = exports['default'];\n\n/***/ }\n/******/ ])\n});\n;\n\n\n/** WEBPACK FOOTER **\n ** ReactRouterBootstrap.min.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 7a9aa334b44e7267aac0\n **/","import ButtonLink from './ButtonLink';\nimport ListGroupItemLink from './ListGroupItemLink';\nimport MenuItemLink from './MenuItemLink';\nimport NavItemLink from './NavItemLink';\nimport RouterModalTrigger from './RouterModalTrigger';\nimport RouterOverlayTrigger from './RouterOverlayTrigger';\n\nexport default {\n ButtonLink,\n ListGroupItemLink,\n MenuItemLink,\n NavItemLink,\n RouterModalTrigger,\n RouterOverlayTrigger\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./webpack/bower-imports-loader.js!./src/index.js\n **/","import React from 'react';\n\nimport {NavItem} from 'react-bootstrap';\nimport LinkMixin from './LinkMixin';\n\nconst NavItemLink = React.createClass({\n mixins: [\n LinkMixin\n ],\n\n render() {\n return (\n \n {this.props.children}\n \n );\n }\n});\n\nexport default NavItemLink;\n\n\n\n/** WEBPACK FOOTER **\n ** ./webpack/bower-imports-loader.js!./src/NavItemLink.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external {\"root\":\"React\",\"commonjs2\":\"react\",\"commonjs\":\"react\",\"amd\":\"react\"}\n ** module id = 2\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_3__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external {\"root\":\"ReactBootstrap\",\"commonjs2\":\"react-bootstrap\",\"commonjs\":\"react-bootstrap\",\"amd\":\"react-bootstrap\"}\n ** module id = 3\n ** module chunks = 0\n **/","import React from 'react';\n\nfunction isLeftClickEvent(event) {\n return event.button === 0;\n}\n\nfunction isModifiedEvent(event) {\n return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);\n}\n\nexport default {\n propTypes: {\n active: React.PropTypes.bool,\n activeClassName: React.PropTypes.string.isRequired,\n disabled: React.PropTypes.bool,\n to: React.PropTypes.string.isRequired,\n params: React.PropTypes.object,\n query: React.PropTypes.object,\n onClick: React.PropTypes.func\n },\n contextTypes: {\n router: React.PropTypes.func.isRequired\n },\n\n getDefaultProps() {\n return {\n activeClassName: 'active'\n };\n },\n\n /**\n * Returns props except those used by this Mixin\n * Gets \"active\" from router if needed.\n * Gets the value of the \"href\" attribute to use on the DOM element.\n * Sets \"onClick\" to \"handleRouteTo\".\n */\n getLinkProps() {\n let {\n to,\n params,\n query,\n ...props\n } = this.props;\n\n if (this.props.active === undefined) {\n props.active = this.context.router.isActive(to, params, query);\n }\n\n props.href = this.context.router.makeHref(to, params, query);\n\n props.onClick = this.handleRouteTo;\n\n return props;\n },\n\n handleRouteTo(event) {\n let allowTransition = true;\n let clickResult;\n\n if (this.props.disabled) {\n event.preventDefault();\n return;\n }\n\n if (this.props.onClick) {\n clickResult = this.props.onClick(event);\n }\n\n if (isModifiedEvent(event) || !isLeftClickEvent(event)) {\n return;\n }\n\n if (clickResult === false || event.defaultPrevented === true) {\n allowTransition = false;\n }\n\n event.preventDefault();\n\n if (allowTransition) {\n this.context.router.transitionTo(this.props.to, this.props.params, this.props.query);\n }\n }\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./webpack/bower-imports-loader.js!./src/LinkMixin.js\n **/","import React from 'react';\n\nimport {Button} from 'react-bootstrap';\nimport LinkMixin from './LinkMixin';\n\nconst ButtonLink = React.createClass({\n mixins: [\n LinkMixin\n ],\n\n render() {\n return (\n \n );\n }\n});\n\nexport default ButtonLink;\n\n\n\n/** WEBPACK FOOTER **\n ** ./webpack/bower-imports-loader.js!./src/ButtonLink.js\n **/","import React from 'react';\n\nimport {ListGroupItem} from 'react-bootstrap';\nimport LinkMixin from './LinkMixin';\n\nconst LinkGroupItemLink = React.createClass({\n mixins: [\n LinkMixin\n ],\n\n render() {\n return (\n \n {this.props.children}\n \n );\n }\n});\n\nexport default LinkGroupItemLink;\n\n\n\n/** WEBPACK FOOTER **\n ** ./webpack/bower-imports-loader.js!./src/ListGroupItemLink.js\n **/","import React from 'react';\n\nimport {MenuItem} from 'react-bootstrap';\nimport LinkMixin from './LinkMixin';\n\nconst MenuItemLink = React.createClass({\n mixins: [\n LinkMixin\n ],\n\n render() {\n let props = this.getLinkProps();\n delete props.onSelect; // this is done on the copy of this.props\n\n return (\n \n {this.props.children}\n \n );\n }\n});\n\nexport default MenuItemLink;\n\n\n\n/** WEBPACK FOOTER **\n ** ./webpack/bower-imports-loader.js!./src/MenuItemLink.js\n **/","import React from 'react';\n\nimport {ModalTrigger} from 'react-bootstrap';\n\nexport default ModalTrigger.withContext({\n router: React.PropTypes.func\n});\n\n\n\n/** WEBPACK FOOTER **\n ** ./webpack/bower-imports-loader.js!./src/RouterModalTrigger.js\n **/","import React from 'react';\n\nimport {OverlayTrigger} from 'react-bootstrap';\n\nexport default OverlayTrigger.withContext({\n router: React.PropTypes.func\n});\n\n\n\n/** WEBPACK FOOTER **\n ** ./webpack/bower-imports-loader.js!./src/RouterOverlayTrigger.js\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/lib/RouterModalTrigger.js b/lib/RouterModalTrigger.js deleted file mode 100644 index 889a7ab..0000000 --- a/lib/RouterModalTrigger.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _reactBootstrapLibModalTrigger = require('react-bootstrap/lib/ModalTrigger'); - -var _reactBootstrapLibModalTrigger2 = _interopRequireDefault(_reactBootstrapLibModalTrigger); - -exports['default'] = _reactBootstrapLibModalTrigger2['default'].withContext({ - router: _react2['default'].PropTypes.func -}); -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/RouterOverlayTrigger.js b/lib/RouterOverlayTrigger.js deleted file mode 100644 index 558cf6e..0000000 --- a/lib/RouterOverlayTrigger.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _reactBootstrapLibOverlayTrigger = require('react-bootstrap/lib/OverlayTrigger'); - -var _reactBootstrapLibOverlayTrigger2 = _interopRequireDefault(_reactBootstrapLibOverlayTrigger); - -exports['default'] = _reactBootstrapLibOverlayTrigger2['default'].withContext({ - router: _react2['default'].PropTypes.func -}); -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/helpers.js b/lib/helpers.js deleted file mode 100644 index 1e3c41c..0000000 --- a/lib/helpers.js +++ /dev/null @@ -1,18 +0,0 @@ -exports.isLeftClick = function(event) { - return event.button === 0; -}; - -exports.isModifiedEvent = function(event) { - return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey); -}; - -exports.withoutProperties = function(object, properties) { - var property, result; - result = {}; - for (property in object) { - if (object.hasOwnProperty(property) && properties.indexOf(property) == -1) { - result[property] = object[property]; - } - } - return result; -}; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b52b882..0000000 --- a/lib/index.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _ButtonLink = require('./ButtonLink'); - -var _ButtonLink2 = _interopRequireDefault(_ButtonLink); - -var _ListGroupItemLink = require('./ListGroupItemLink'); - -var _ListGroupItemLink2 = _interopRequireDefault(_ListGroupItemLink); - -var _MenuItemLink = require('./MenuItemLink'); - -var _MenuItemLink2 = _interopRequireDefault(_MenuItemLink); - -var _NavItemLink = require('./NavItemLink'); - -var _NavItemLink2 = _interopRequireDefault(_NavItemLink); - -var _RouterModalTrigger = require('./RouterModalTrigger'); - -var _RouterModalTrigger2 = _interopRequireDefault(_RouterModalTrigger); - -var _RouterOverlayTrigger = require('./RouterOverlayTrigger'); - -var _RouterOverlayTrigger2 = _interopRequireDefault(_RouterOverlayTrigger); - -exports['default'] = { - ButtonLink: _ButtonLink2['default'], - ListGroupItemLink: _ListGroupItemLink2['default'], - MenuItemLink: _MenuItemLink2['default'], - NavItemLink: _NavItemLink2['default'], - RouterModalTrigger: _RouterModalTrigger2['default'], - RouterOverlayTrigger: _RouterOverlayTrigger2['default'] -}; -module.exports = exports['default']; \ No newline at end of file diff --git a/package.json b/package.json index 6294020..0366655 100644 --- a/package.json +++ b/package.json @@ -5,16 +5,21 @@ "main": "./lib/index.js", "scripts": { "prepublish": "npm run build", - "build": "babel src --out-dir=lib && webpack && COMPRESS=1 webpack", + "build": "babel src --out-dir=lib && webpack && COMPRESS=1 webpack && npm run bower-prepare", "test": "npm run lint && karma start --single-run", "tdd": "karma start", "visual-test": "webpack-dev-server --config webpack.test.config.babel.js", - "lint": "eslint ./" + "lint": "eslint ./", + "bower-prepare": "babel-node scripts/bower-prepare.js", + "patch": "release patch", + "minor": "release minor", + "major": "release major" }, "repository": { "type": "git", "url": "git@github.com:react-bootstrap/react-router-bootstrap.git" }, + "bowerRepo": "git@github.com:react-bootstrap/react-router-bootstrap-bower.git", "keywords": [ "react", "react-router", @@ -40,6 +45,7 @@ "babel-loader": "^5.1.4", "bootstrap": "^3.3.1", "chai": "^3.0.0", + "colors": "^1.1.2", "eslint": "^0.24.0", "eslint-plugin-babel": "^1.0.0", "eslint-plugin-mocha": "^0.4.0", @@ -50,14 +56,19 @@ "karma-mocha-reporter": "^1.0.2", "karma-phantomjs-launcher": "^0.2.0", "karma-webpack": "^1.5.0", + "lodash": "^3.10.0", "mocha": "^2.1.0", + "mt-changelog": "^0.5.3", "node-libs-browser": "^0.5.2", "phantomjs": "^1.9.13", "react": ">0.10.0", "react-bootstrap": ">=0.15", "react-router": ">=0.13.1", + "release-script": "^0.1.0", + "shelljs": "^0.5.1", "webpack": "^1.4.15", - "webpack-dev-server": "^1.7.0" + "webpack-dev-server": "^1.7.0", + "yargs": "^3.15.0" }, "files": [ "lib" diff --git a/scripts/bower-prepare.js b/scripts/bower-prepare.js new file mode 100644 index 0000000..02acfa4 --- /dev/null +++ b/scripts/bower-prepare.js @@ -0,0 +1,70 @@ +/* globals cat, config, cp, mkdir, rm, test */ +/* eslint curly: 0 */ +import 'colors'; +import 'shelljs/global'; +import path from 'path'; +import _ from 'lodash'; +import yargs from 'yargs'; + +// do not die on errors +config.fatal = false; + +//------------------------------------------------------------------------------ +// constants +const repoRoot = path.resolve(__dirname, '../'); +const libFolder = path.join(repoRoot, 'lib'); +const bowerRoot = path.join(repoRoot, 'amd'); +const bowerTemplate = path.join(repoRoot, 'bower.template.json'); +const license = path.join(repoRoot, 'LICENSE'); + + +//------------------------------------------------------------------------------ +// command line options +const argv = yargs + .usage('Usage: $0 [--verbose]') + .example('$0', 'Prepare bower package for releasing') + .option('verbose', { + demand: false, + default: false, + describe: 'Increased debug output' + }) + .argv; + +if (argv.dryRun) console.log('DRY RUN'.magenta); + +config.silent = !argv.verbose; + + +//------------------------------------------------------------------------------ +// functions +function bower() { + console.log('Creating: '.cyan + 'bower package'.green); + + rm('-rf', bowerRoot); + mkdir('-p', bowerRoot); + + // generate bower.json from template + const pkg = JSON.parse(cat(path.join(repoRoot, 'package.json'))); + const template = _.template(cat(bowerTemplate)); + const bowerConfigObject = template({ pkg }); + const json = JSON.stringify(JSON.parse(bowerConfigObject), null, 2); // proper formatting hack + json.to(path.join(bowerRoot, 'bower.json')); + + // copy readme and license + const readmeBower = path.join(repoRoot, 'README.bower.md'); + const readme = path.join(repoRoot, 'README.md'); + if (test('-e', readmeBower)) { + cp(readmeBower, path.join(bowerRoot, 'README.md')); + } else { + cp(readme, bowerRoot); + } + if (test('-e', license)) cp(license, bowerRoot); + + // copy distr files + cp('-r', libFolder, bowerRoot); + + console.log('Created: '.cyan + 'bower package'.green); +} + +//------------------------------------------------------------------------------ +bower();