diff --git a/bin/gitgraph.js b/bin/gitgraph.js index 62b030d..ff9f360 100644 --- a/bin/gitgraph.js +++ b/bin/gitgraph.js @@ -1,4 +1,4 @@ -var gitlost = require('../lib/graph'); +import gitlost from '../lib/graph'; settings = JSON.parse(process.argv.slice(2).join(' ') || '{}'); gitlost.graph(settings).then(function (dot) { console.log(dot); diff --git a/bin/gitlost.js b/bin/gitlost.js index 48fecf9..c423f92 100644 --- a/bin/gitlost.js +++ b/bin/gitlost.js @@ -1,5 +1,5 @@ -var opn = require('opn'); -var server = require("../lib/server.js"); +import * as opn from 'opn'; +import server from "../lib/server"; opn('http://localhost:6776', {app: 'chrome'}); server.listen(6776); diff --git a/lib/graph.js b/lib/graph.js index e2b4f21..4bfb20b 100644 --- a/lib/graph.js +++ b/lib/graph.js @@ -1,5 +1,7 @@ -var child_process = require('child_process'); -var md5 = require('md5'); +"use strict"; + +import * as child_process from 'child_process'; +import * as md5 from 'md5'; var carot = '^'; if (process.platform === 'win32') { @@ -64,11 +66,11 @@ function hsl_to_rgb(h, s, l){ var color_hash = function(text) { text = text.match(/[^\/]+$/)[0]; - hash = parseInt('0x' + md5(text).slice(-5)); + var hash = parseInt('0x' + md5(text).slice(-5)); var h = (((hash >> 9) & 0x1ff) ^ 0x109) / 512; // map [0,127] to ~[ 0, 1) var s = ((((hash >> 5) & 0x3f) ^ 0x2f) + 36) / 100; // map [0, 63] to [.36, .99] var l = ((hash & 0x1f) + 24) / 100; // map [0, 31] to [.24, .55] - rgb = hsl_to_rgb(h, s, l); + var rgb = hsl_to_rgb(h, s, l); rgb = (rgb[0] << 16) + (rgb[1] << 8) + rgb[2]; //console.log('/* ' + hash.toString(16) + ' - ' + [h, s, l] + '*/') return '#' + ('000000' + rgb.toString(16)).slice(-6) @@ -165,6 +167,7 @@ function graph(settings) { }; }) .sort(function (a, b) { + var ax, bx; return ((ax = settings.branches.indexOf(a.ref_short)) !== -1 ? ax : settings.branches.length) - ((bx = settings.branches.indexOf(b.ref_short)) !== -1 ? bx : settings.branches.length); }); }); @@ -278,7 +281,4 @@ function graph(settings) { }); } -module.exports = { - graph: graph, - queue_cmd: queue_cmd -}; +export { graph, queue_cmd }; diff --git a/lib/server.js b/lib/server.js index 4a3bcbf..44e463a 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1,11 +1,10 @@ -var http = require('http'); -var child_process = require('child_process'); +import * as http from 'http'; var fs = require('fs'); -var path = require('path'); -var EventEmitter = require('events'); -var gitlost = require('./graph'); +import * as path from 'path'; +import * as EventEmitter from 'events'; +import * as gitlost from './graph'; -var webdir = path.join(__dirname, '../web'); +var webdir = __dirname; var vizjs = path.join(__dirname, '../node_modules/viz.js/viz.js'); var mimetypes = { @@ -280,4 +279,4 @@ server.on('request', function (request, response) { } }); -module.exports = server; +export default server; diff --git a/package.json b/package.json index 3bbe8e7..7533aa9 100644 --- a/package.json +++ b/package.json @@ -5,16 +5,30 @@ "main": "./lib/graph.js", "bin": "./bin/gitlost.js", "dependencies": { + "bootstrap": "^3.0.0", "bootstrap-menu": "^1.0.14", - "bootstrap3-dialog": "^1.35.3", + "bootstrap-select": "^1.12.4", + "bootstrap3-dialog": "^1.35.4", "d3": "^4.13.0", "d3-graphviz": "^1.3.4", + "jquery": "^3.3.1", "md5": "^2.2.1", "opn": "^4.0.2", "sortablejs": "^1.5.1" }, - "devDependencies": {}, + "devDependencies": { + "babel-loader": "^7.1.4", + "css-loader": "^0.28.10", + "file-loader": "^1.1.11", + "style-loader": "^0.20.3", + "url-loader": "^1.0.1", + "webpack": "^4.1.1", + "webpack-cli": "^2.0.10", + "webpack-node-externals": "^1.6.0" + }, "scripts": { + "build": "webpack && copy web\\graph.html dist\\graph.html && copy node_modules\\viz.js\\viz.js dist\\viz.js", + "start": "./dist/gitlost.js", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/web/BootstrapMenu.js b/web/BootstrapMenu.js deleted file mode 100644 index baa3a0c..0000000 --- a/web/BootstrapMenu.js +++ /dev/null @@ -1,2589 +0,0 @@ -/******/ (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__) { - - /* webpack entry file to build a standalone browser script. */ - window.BootstrapMenu = __webpack_require__(1); - - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var classNames = __webpack_require__(2); - var $ = __webpack_require__(3); - __webpack_require__(4); - - // modular lodash requires - var _ = function() { - throw new Error('Custom lodash build for BootstrapMenu. lodash chaining is not included'); - }; - - _.noop = __webpack_require__(6); - _.each = __webpack_require__(7); - _.contains = __webpack_require__(34); - _.extend = __webpack_require__(42); - _.uniqueId = __webpack_require__(49); - _.isFunction = __webpack_require__(19); - - - var defaultOptions = { - /* container of the context menu, where it will be created and where - * event listeners will be installed. */ - container: 'body', - - /* user-defined function to obtain specific data about the currently - * opened element, to pass it to the rest of user-defined functions - * of an action. */ - fetchElementData: _.noop, - - /* what the source of the context menu should be when opened. - * Valid values are 'mouse' and 'element'. */ - menuSource: 'mouse', - - /* how to calculate the position of the context menu based on its source. - * Valid values are 'aboveLeft', 'aboveRight', 'belowLeft', and 'belowRight'. */ - menuPosition: 'belowLeft', - - /* the event to listen to open the menu. - * Valid values are 'click', 'right-click', 'hover' */ - menuEvent: 'right-click', // TODO rename to menuAction in next mayor version - - /* group actions to render them next to each other, with a separator - * between each group. */ - actionsGroups: [], - - /* message to show when there are no actions to show in a menu - * (isShown() returned false on all actions) */ - noActionsMessage: 'No available actions', - - /* In some weird cases, another plugin may be installing 'click' listeners - * in the anchors used for each action of the context menu, and stopping - * the event bubbling before it reachs this plugin's listener. - * - * For those cases, _actionSelectEvent can be used to change the event we - * listen to, for example to 'mousedown'. - * - * Unless the context menu is not working due to this and a workaround is - * needed, this option can be safely ignored. - */ - _actionSelectEvent: 'click' - }; - - function renderMenu(_this) { - var $menu = $('