diff --git a/ChangeLog.md b/ChangeLog.md index 8557ce8..285c69a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -9,18 +9,30 @@ - env variable `DEBUG=ssh2` will put the `ssh2` module into debug mode - env variable `DEBUG=WebSSH2` will output additional debug messages for functions and events in the application (not including the ssh2 module debug) +- using Grunt to pull js and css source files from other modules `npm run build` to rebuild these if changed or updated. +- `useminified` option in `config.json` to enable using minified client side javascript (true) defaults to false (non-minified) ### Changed -- erorr handling in public/client.js +- error handling in public/client.js - moved socket.io operations to their own file /socket/index.js, more changes like this to come (./socket/index.js) - all session based variables are now under the req.session.ssh property or socket.request.ssh (./index.js) - moved SSH algorithms to config.json and defined as a session variable (..session.ssh.algorithms) -- prep for future feature to define algorithims in header or some other method to enable seperate ciphers per host +- minified and combined all js files to a single js in `./public/webssh2.min.js` also included a sourcemap `./public/webssh2.min.js` which maps to `./public/webssh2.js` for easier troubleshooting. +- combined all css files to a single css in `./public/webssh2.css` +- minified all css files to a single css in `./public/webssh2.min.css` +- copied all unmodified source css and js to /public/src/css and /public/src/js respectively (for troubleshooting/etc) +- sourcemaps of all minified code (in /public/src and /public/src/js) +- renamed `client.htm` to `client-full.htm` +- created `client-min.htm` to serve minified javascript ### Fixed - Multiple errors may ovewrite status bar which would cause confusion as to what originally caused the error. Example, ssh server disconnects which prompts a cascade of events (conn.on('end'), socket.on('disconnect'), conn.on('close')) and the original reason (conn.on('end')) would be lost and the user would erroneously receive a WEBSOCKET error as the last event to fire would be the websocket connection closing from the app. - ensure ssh session is closed when a browser disconnects from the websocket +### Removed +- Express Static References directly to module source directories due to concatenating and minifying js/css + ## [0.0.5] - 2017-0323 ### Added - Added experimental support for logging (see Readme) diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..5c18456 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,73 @@ +module.exports = function (grunt) { + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + copy: { + main: { + files: [ + { + expand: true, + flatten: true, + src: [ + 'node_modules/xterm/dist/xterm.css', + 'src/css/style.css' + ], + dest: 'public/src/css' + }, + { + expand: true, + flatten: true, + src: [ + 'node_modules/xterm/dist/xterm.js', + 'node_modules/xterm/dist/xterm.js.map', + 'node_modules/xterm/dist/addons/fit/fit.js', + 'node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js', + 'node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js.map', + 'src/js/client.js' + ], + dest: 'public/src/js' + } + ] + } + }, + concat: { + options: { + sourceMap: true, + sourceMapName: 'public/src/webssh2.concat.map', + sourceMapStyle: 'embed' + }, + css: { + src: ['public/src/css/*.css'], + dest: 'public/webssh2.css' + }, + js: { + src: [ + 'public/src/js/xterm.js', + 'public/src/js/fit.js', + 'public/src/js/socket.io.js', + 'public/src/js/client.js' + ], + dest: 'public/webssh2.js' + } + }, + uglify: { + options: { + banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n', + sourceMap: true, + sourceMapName: 'public/src/webssh2.min.map' + }, + build: { + src: ['public/src/js/xterm.js', 'public/src/js/fit.js', 'public/src/js/socket.io.js', 'public/src/js/client.js'], + dest: 'public/webssh2.min.js' + } + } + }) + + // Load the plugin that provides the "uglify" task. + grunt.loadNpmTasks('grunt-contrib-copy') + grunt.loadNpmTasks('grunt-contrib-concat') + grunt.loadNpmTasks('grunt-contrib-uglify') + + // Default task(s). + grunt.registerTask('default', ['copy', 'concat', 'uglify']) +} diff --git a/README.md b/README.md index b6d8f8f..19cc61d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Bare bones example of using SSH2 as a client on a host to proxy a Websocket / So # Instructions To install: -1. Clone to a location somewhere and `npm install` +1. Clone to a location somewhere and `npm install --production`. If you want to develop and rebuild javascript and other files utilize `npm install` instead. 2. If desired, edit config.json to change the listener to your liking. There are also some default options which may be definied for a few of the variables. @@ -46,6 +46,8 @@ headerBackground= - optional background color of header to display on page * **ssh.term** - _string_ - Specify terminal emulation to use, defaults to `xterm-color` +* **useminified** - _boolean_ - Choose between ./public/client-full.htm (false/non-minified) or ./public/client-min.htm (true/minified js), defaults to false (non-minified version) + * **header.text** - _string_ - Specify header text, defaults to `My Header` but may also be set to `null`. * **header.background** - _string_ - Header background, defaults to `green`. @@ -151,3 +153,7 @@ Clicking `Start logging` on the status bar will log all data to the client. A `D http://localhost:2222/ssh/host/192.168.1.1?port=2244&header=My%20Header&color=red +# Tips +* If you want to add custom JavaScript to the browser client you can either modify `./public/client-(full|min).html` and add a ** - - - + +