Refactor TS build and fix testing

This change is largely just moving files with minor tweaks to them to fix,
the rest of the commit is build process changes:

- The addons/ and test/ dirs have been moved to src/
- The build directory has been removed
- TypeScript builds are output in out/, this is where tests are run
- The demo now relies on the dist/ build which is performed as part of ./bin/build
- Addons are now shipped under the ./build directory
This commit is contained in:
Daniel Imms 2016-10-31 21:22:21 -07:00
parent a995b610cf
commit 56ecc77dfc
174 changed files with 50 additions and 37 deletions

2
.gitignore vendored
View File

@ -1,6 +1,5 @@
node_modules/ node_modules/
*.swp *.swp
build/*
.lock-wscript .lock-wscript
out/ out/
Makefile.gyp Makefile.gyp
@ -12,3 +11,4 @@ docs/
npm-debug.log npm-debug.log
/.idea/ /.idea/
.env .env
dist/*

View File

@ -1,5 +1,17 @@
#! /usr/bin/env sh #! /usr/bin/env bash
mkdir -p build # Build all TypeScript files (including tests) to out/
browserify src/xterm.js --standalone Terminal -p [ tsify ] --outfile build/xterm.js tsc
cp src/xterm.css build/xterm.css
# Concat all xterm.js files into a single file and output as a UMD to dist/xterm.js
browserify out/xterm.js --standalone Terminal -p [ tsify ] --outfile dist/xterm.js
# Copy all CSS files from src/ to dist/
cd src
find . -name '*.css' | cpio -pdm ../dist
cd ..
# Copy addons from out/ to dist/
cd out/addons
find . -name '*.js' | cpio -pdm ../../dist/addons
cd ../..

View File

@ -8,7 +8,6 @@ var terminals = {},
logs = {}; logs = {};
app.use('/build', express.static(__dirname + '/../build')); app.use('/build', express.static(__dirname + '/../build'));
app.use('/addons', express.static(__dirname + '/../addons'));
app.get('/', function(req, res){ app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html'); res.sendFile(__dirname + '/index.html');

View File

@ -3,13 +3,13 @@
<head> <head>
<title>xterm.js demo</title> <title>xterm.js demo</title>
<link rel="stylesheet" href="../build/xterm.css" /> <link rel="stylesheet" href="../build/xterm.css" />
<link rel="stylesheet" href="../addons/fullscreen/fullscreen.css" /> <link rel="stylesheet" href="../build/addons/fullscreen/fullscreen.css" />
<link rel="stylesheet" href="style.css" /> <link rel="stylesheet" href="style.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
<script src="../build/xterm.js" ></script> <script src="/build/xterm.js" ></script>
<script src="../addons/attach/attach.js" ></script> <script src="/build/addons/attach/attach.js" ></script>
<script src="../addons/fit/fit.js" ></script> <script src="/build/addons/fit/fit.js" ></script>
<script src="../addons/fullscreen/fullscreen.js" ></script> <script src="/build/addons/fullscreen/fullscreen.js" ></script>
</head> </head>
<body> <body>
<h1>xterm.js: xterm, in the browser</h1> <h1>xterm.js: xterm, in the browser</h1>

View File

@ -26,8 +26,8 @@
"typescript": "^2.0.3" "typescript": "^2.0.3"
}, },
"scripts": { "scripts": {
"start": "nodemon --watch src --watch addons --exec bash -c './bin/build && node demo/app'", "start": "nodemon --watch src --watch addons --watch demo --exec bash -c './bin/build && node demo/app'",
"test": "./bin/build && mocha --recursive ./test/*test.js ./test/**/*test.js", "test": "./bin/build && mocha --recursive ./out",
"build:docs": "jsdoc -c jsdoc.json", "build:docs": "jsdoc -c jsdoc.json",
"build": "./bin/build" "build": "./bin/build"
} }

View File

@ -11,12 +11,12 @@
/* /*
* CommonJS environment * CommonJS environment
*/ */
module.exports = attach(require('../../dist/xterm')); module.exports = attach(require('../../xterm'));
} else if (typeof define == 'function') { } else if (typeof define == 'function') {
/* /*
* Require.js is available * Require.js is available
*/ */
define(['../../dist/xterm'], attach); define(['../../xterm'], attach);
} else { } else {
/* /*
* Plain browser environment * Plain browser environment

View File

@ -16,12 +16,12 @@
/* /*
* CommonJS environment * CommonJS environment
*/ */
module.exports = fit(require('../../dist/xterm')); module.exports = fit(require('../../xterm'));
} else if (typeof define == 'function') { } else if (typeof define == 'function') {
/* /*
* Require.js is available * Require.js is available
*/ */
define(['../../dist/xterm'], fit); define(['../../xterm'], fit);
} else { } else {
/* /*
* Plain browser environment * Plain browser environment

View File

@ -15,12 +15,12 @@
/* /*
* CommonJS environment * CommonJS environment
*/ */
module.exports = fullscreen(require('../../dist/xterm')); module.exports = fullscreen(require('../../xterm'));
} else if (typeof define == 'function') { } else if (typeof define == 'function') {
/* /*
* Require.js is available * Require.js is available
*/ */
define(['../../dist/xterm'], fullscreen); define(['../../xterm'], fullscreen);
} else { } else {
/* /*
* Plain browser environment * Plain browser environment

View File

@ -3,12 +3,12 @@
/* /*
* CommonJS environment * CommonJS environment
*/ */
module.exports = linkify(require('../../dist/xterm')); module.exports = linkify(require('../../xterm'));
} else if (typeof define == 'function') { } else if (typeof define == 'function') {
/* /*
* Require.js is available * Require.js is available
*/ */
define(['../../dist/xterm'], linkify); define(['../../xterm'], linkify);
} else { } else {
/* /*
* Plain browser environment * Plain browser environment

View File

@ -11,12 +11,12 @@
/* /*
* CommonJS environment * CommonJS environment
*/ */
module.exports = attach(require('../../src/xterm')); module.exports = attach(require('../../xterm'));
} else if (typeof define == 'function') { } else if (typeof define == 'function') {
/* /*
* Require.js is available * Require.js is available
*/ */
define(['../../src/xterm'], attach); define(['../../xterm'], attach);
} else { } else {
/* /*
* Plain browser environment * Plain browser environment

View File

@ -1,5 +1,5 @@
var assert = require('chai').assert; var assert = require('chai').assert;
var Terminal = require('../../dist/xterm'); var Terminal = require('../../xterm');
var linkify = require('../../addons/linkify/linkify'); var linkify = require('../../addons/linkify/linkify');
describe('linkify addon', function () { describe('linkify addon', function () {

View File

@ -1,11 +1,10 @@
var assert = require('chai').assert; var assert = require('chai').assert;
var Terminal = require('../../src/xterm'); var Terminal = require('../../xterm');
var distTerminal = require('../../dist/xterm');
describe('xterm.js addons', function() { describe('xterm.js addons', function() {
it('should load addons with Terminal.loadAddon', function () { it('should load addons with Terminal.loadAddon', function () {
Terminal.loadAddon('attach'); Terminal.loadAddon('attach');
// Test that addon was loaded successfully // Test that addon was loaded successfully
assert.equal(typeof distTerminal.prototype.attach, 'function'); assert.equal(typeof Terminal.prototype.attach, 'function');
}); });
}); });

View File

@ -1,6 +1,6 @@
var assert = require('chai').assert; var assert = require('chai').assert;
var Terminal = require('../src/xterm'); var Terminal = require('../xterm');
var Clipboard = require('../src/handlers/Clipboard'); var Clipboard = require('../handlers/Clipboard');
describe('evaluateCopiedTextProcessing', function () { describe('evaluateCopiedTextProcessing', function () {

View File

@ -1,5 +1,5 @@
var assert = require('chai').assert; var assert = require('chai').assert;
var Terminal = require('../build/xterm'); var Terminal = require('../xterm');
describe('CompositionHelper', function () { describe('CompositionHelper', function () {
var terminal; var terminal;

View File

@ -2,7 +2,7 @@ var glob = require('glob');
var fs = require('fs'); var fs = require('fs');
var pty = require('pty.js'); var pty = require('pty.js');
var sleep = require('sleep'); var sleep = require('sleep');
var Terminal = require('../build/xterm'); var Terminal = require('../xterm');
var CONSOLE_LOG = console.log; var CONSOLE_LOG = console.log;
@ -80,9 +80,10 @@ describe('xterm output comparison', function() {
// omit stack trace for escape sequence files // omit stack trace for escape sequence files
Error.stackTraceLimit = 0; Error.stackTraceLimit = 0;
var files = glob.sync('test/escape_sequence_files/*.in'); var files = glob.sync('**/escape_sequence_files/*.in');
// only successful tests for now // only successful tests for now
var successful = [0, 2, 6, 12, 13, 18, 20, 22, 27, 28]; var successful = [0, 2, 6, 12, 13, 18, 20, 22, 27, 28];
console.log(files);
for (var a in successful) { for (var a in successful) {
var i = successful[a]; var i = successful[a];
(function(filename){ (function(filename){

Some files were not shown because too many files have changed in this diff Show More