Skip to content

Commit

Permalink
Initial TypeScript conversion
Browse files Browse the repository at this point in the history
This is a straight TS conversion, without significant changes to the
API. The work was started by @jason0x43 and completed by @nicknisi.

In addition to the basic conversion, several other project-level changes
were made:

- Move from custom dojo2 to dojo-core, etc.
- Use pre-release TS version of Dig Dug
- Use `files` in package.json instead of .npmignore for package building
- A new intern-dev package is used for all the build lifecycle functions
  (build, clean, lint, etc.)

[ci skip]
  • Loading branch information
jason0x43 committed Apr 5, 2017
1 parent 01b11e4 commit be5bd35
Show file tree
Hide file tree
Showing 95 changed files with 12,398 additions and 11,632 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -6,6 +6,7 @@ saucelabs
testingbot
browserstack
coverage-final.json
_build/
src/**/*.js
benchmark.json
baselines.json
*.tgz
4 changes: 2 additions & 2 deletions .jshintrc
Expand Up @@ -32,7 +32,7 @@
"multistr": false,
"newcap": true,
"noarg": true,
"node": false,
"node": true,
"noempty": false,
"nonew": true,
"nonstandard": false,
Expand Down Expand Up @@ -67,7 +67,7 @@
"maxlen": 120,
"indent": 4,
"maxerr": 250,
"predef": [ "require", "define" ],
"predef": [ "require", "define", "Promise" ],
"quotmark": "single",
"maxcomplexity": 10
}
8 changes: 4 additions & 4 deletions client.html
Expand Up @@ -50,10 +50,10 @@
dojo: 'intern/browser_modules/dojo',
chai: 'intern/browser_modules/chai/chai',
diff: 'intern/browser_modules/diff/diff',
// benchmark requires lodash and platform
benchmark: 'intern/browser_modules/benchmark/benchmark',
lodash: 'intern/browser_modules/lodash-amd/main',
platform: 'intern/browser_modules/platform/platform'
// benchmark requires lodash and platform
benchmark: 'intern/browser_modules/benchmark/benchmark',
lodash: 'intern/browser_modules/lodash-amd/main',
platform: 'intern/browser_modules/platform/platform'
},
'*': {
'intern/dojo': 'intern/browser_modules/dojo'
Expand Down
42 changes: 35 additions & 7 deletions package.json
@@ -1,20 +1,22 @@
{
"name": "intern",
"version": "3.5.0-pre",
"main": "./main.js",
"types": "./typings/intern/intern.d.ts",
"version": "4.0.0-pre",
"main": "main.js",
"description": "Intern. A next-generation code testing stack for JavaScript.",
"repository": {
"type": "git",
"url": "https://github.com/theintern/intern.git"
},
"license": "BSD-3-Clause",
"dependencies": {
"@types/source-map": "~0.1.28",
"@types/benchmark": "~1.0.30",
"@types/chai": "~3.4.34",
"benchmark": "2.1.1",
"chai": "3.5.0",
"charm": "0.2.0",
"diff": "1.1.0",
"digdug": "~1.6.0",
"digdug": "https://github.com/jason0x43/digdug/releases/download/2.0.0-pre/digdug-2.0.0-pre.tgz",
"dojo": "2.0.0-alpha.7",
"glob": "7.0.3",
"istanbul": "0.4.1",
Expand All @@ -27,13 +29,27 @@
"@types/node": "6.0.48"
},
"devDependencies": {
"intern": "3.2.3"
"@types/chokidar": "~1.4.29",
"@types/diff": "~0.0.31",
"@types/glob": "~5.0.30",
"@types/grunt": "~0.4.20",
"@types/node": "~6.0.0",
"intern": "~3.4.2",
"intern-dev": "https://github.com/theintern/intern-dev/releases/download/0.1.2/intern-dev-0.1.2.tgz"
},
"peerDependencies": {
"typescript": "~2.1.4",
"tslint": "~4.0.0"
},
"scripts": {
"build": "intern-dev-clean && intern-dev-build",
"clean": "intern-dev-clean",
"install": "node support/fixdeps.js",
"lint": "intern-dev-lint",
"release": "intern-dev-release",
"test": "intern-dev-build && intern-dev-test",
"update": "node support/fixdeps.js",
"release": "node support/release.js",
"test": "node support/test.js"
"watch": "intern-dev-watch"
},
"bugs": "https://github.com/theintern/intern/issues",
"files": [
Expand Down Expand Up @@ -72,5 +88,17 @@
"bin": {
"intern-client": "./bin/intern-client.js",
"intern-runner": "./bin/intern-runner.js"
},
"internDev": {
"resources": {
"src": [
"tests/example.intern.js"
],
".": [
"tests/**/*.xml",
"tests/**/*.js"
]
},
"testConfig": "tests/selftest.intern.js"
}
}
62 changes: 32 additions & 30 deletions src/chai.ts
@@ -1,30 +1,32 @@
define([ 'chai' ], function (chai) {
// ensure that chai-generated errors always include a stack
chai.config.includeStack = true;

return {
/**
* AMD plugin API interface for easy loading of chai assertion interfaces.
*/
load: function (id, parentRequire, callback) {
if (!id) {
callback(chai);
return;
}

if (!chai[id]) {
throw new Error('Invalid chai interface "' + id + '"');
}

if (!chai[id].AssertionError) {
chai[id].AssertionError = chai.AssertionError;
}

callback(chai[id]);
},

normalize: function (id) {
return id;
}
};
});
/**
* AMD plugin API interface for easy loading of chai assertion interfaces.
*/

import * as chai from 'chai';
import { IRequire } from 'dojo/loader';

// Ensure that chai-generated errors always include a stack
chai.config.includeStack = true;

export function load(id: string, _pluginRequire: IRequire, callback: Function) {
if (!id) {
callback(chai);
return;
}

const iface: any = (<any> chai)[id];

if (!iface) {
throw new Error('Invalid chai interface "' + id + '"');
}

if (!iface.AssertionError) {
iface.AssertionError = chai.AssertionError;
}

callback(iface);
}

export function normalize(id: string) {
return id;
}
56 changes: 30 additions & 26 deletions src/client.ts
@@ -1,41 +1,45 @@
/* jshint node:true, es3:false */
import { IDefine, IRequire } from 'dojo/loader';

declare const define: IDefine;

if (typeof process !== 'undefined' && typeof define === 'undefined') {
(function () {
require('dojo/loader')((this.__internConfig = {
baseUrl: process.cwd().replace(/\\/g, '/'),
packages: [
{ name: 'intern', location: __dirname.replace(/\\/g, '/') }
],
map: {
intern: {
dojo: 'intern/browser_modules/dojo',
chai: 'intern/browser_modules/chai/chai',
diff: 'intern/browser_modules/diff/diff',
// benchmark requires lodash and platform
benchmark: 'intern/browser_modules/benchmark/benchmark',
lodash: 'intern/browser_modules/lodash-amd/main',
platform: 'intern/browser_modules/platform/platform'
},
'*': {
'intern/dojo': 'intern/browser_modules/dojo'
}
require('dojo/loader')(((<any> global).__internConfig = {
baseUrl: process.cwd().replace(/\\/g, '/'),
packages: [
{ name: 'intern', location: __dirname.replace(/\\/g, '/') }
],
map: {
intern: {
dojo: 'intern/browser_modules/dojo',
chai: 'intern/browser_modules/chai/chai',
diff: 'intern/browser_modules/diff/diff',
// benchmark requires lodash and platform
benchmark: 'intern/browser_modules/benchmark/benchmark',
lodash: 'intern/browser_modules/lodash-amd/main',
platform: 'intern/browser_modules/platform/platform'
},
'*': {
'intern/dojo': 'intern/browser_modules/dojo'
}
}), [ 'intern/client' ]);
})();
}
}), [ 'intern/client' ]);
}
else {
define([
const global = (new Function('return this'))();
const amdRequire: IRequire = <any> require;

amdRequire([
'./lib/executors/PreExecutor',
'dojo/has!host-node?./lib/exitHandler'
], function (PreExecutor, exitHandler) {
var executor = new PreExecutor({
const executor = new PreExecutor.default({
defaultLoaderOptions: (function () {
return this;
return global;
})().__internConfig,
executorId: 'client'
});

var promise = executor.run();
const promise = executor.run();

if (exitHandler) {
exitHandler(process, promise, 10000);
Expand Down

0 comments on commit be5bd35

Please sign in to comment.