diff --git a/.gitignore b/.gitignore index 51d4adb2..c20fb731 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ -dist +*.tgz bower_components coverage +dist node_modules npm-debug.log +package-lock.json tmp -.idea diff --git a/.npmignore b/.npmignore index 5315c373..adc81e3b 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,16 @@ +.editorconfig +.eslintrc.js +*.tgz +*.yml +assets bower_components +ci coverage +examples node_modules npm-debug.log -tmp +src tests +tmp +tsconfig.json +tslint.json diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/.travis.yml b/.travis.yml index 32af1797..721b9c82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ sudo: required language: node_js -node_js: 6 +node_js: 8 before_script: - "sudo chown root /opt/google/chrome/chrome-sandbox" @@ -12,7 +12,7 @@ addons: chrome: stable install: - - ./ci/install.sh + - npm run setup script: - npm run ci diff --git a/LICENSE b/LICENSE index 5c42e576..a943f505 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (C) 2016-2017 Erik Barke, Monounity. +Copyright (C) 2016-2018 Erik Barke, Monounity. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 0c9228b0..375cdece 100644 --- a/README.md +++ b/README.md @@ -647,4 +647,4 @@ These are the environments reported failing/working: This software is licensed with the MIT license. -© 2016-2017 Erik Barke, Monounity +© 2016-2018 Erik Barke, Monounity diff --git a/appveyor.yml b/appveyor.yml index a869413e..24977a76 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,12 +1,12 @@ environment: - nodejs_version: "6" + nodejs_version: "8" install: - ps: Install-Product node $env:nodejs_version - set PATH=%APPDATA%\npm;%PATH% - node -v - npm -v - - ci\install.bat + - npm run setup test_script: - npm run ci diff --git a/ci/install.bat b/ci/install.bat deleted file mode 100755 index a93a3479..00000000 --- a/ci/install.bat +++ /dev/null @@ -1,27 +0,0 @@ -cd examples\angular2 -call npm i - -cd ..\angularjs -call npm i - -cd ..\gulp -call npm i - -cd ..\mocha -call npm i - -cd ..\typescript-1.6.2 -call npm i - -cd ..\typescript-latest -call npm i - -cd ..\..\tests\integration-1.8.10 -call npm i - -cd ..\integration-latest -call npm i -call npm run prepare - -cd ..\.. -call npm i diff --git a/ci/install.sh b/ci/install.sh deleted file mode 100755 index d40b2a3f..00000000 --- a/ci/install.sh +++ /dev/null @@ -1,41 +0,0 @@ -#/bin/sh - -echo "npm -v" -npm -v - -cd examples/angular2 -pwd -npm i - -cd ../angularjs -pwd -npm i - -cd ../gulp -pwd -npm i - -cd ../mocha -pwd -npm i - -cd ../typescript-1.6.2 -pwd -npm i - -cd ../typescript-latest -pwd -npm i - -cd ../../tests/integration-1.8.10 -pwd -npm i - -cd ../integration-latest -pwd -npm i -npm run prepare - -cd ../.. -pwd -npm i diff --git a/ci/run.js b/ci/run.js deleted file mode 100644 index c64958fb..00000000 --- a/ci/run.js +++ /dev/null @@ -1,48 +0,0 @@ -var spawn = require("cross-spawn"); - -var command = "npm run dev:ci"; - -// The pyramid of doom :( If you have a better idea, (which doesn't -// involve wait.for / node-gyp / fibers) please create a pull request, -// but bear in mind that this has to run on windows machines as well... -execute("examples/angular2", command, function() { - execute("examples/angularjs", command, function() { - execute("examples/mocha", command, function() { - execute("examples/typescript-1.6.2", command, function() { - execute("examples/typescript-latest", command, function() { - - execute("tests/integration-1.8.10", command, function() { - execute("tests/integration-1.8.10", command + ":angular2", function() { - execute("tests/integration-1.8.10", command + ":react", function() { - - execute("tests/integration-latest", command, function() { - execute("tests/integration-latest", command + ":angular2", function() { - execute("tests/integration-latest", command + ":core", function() { - execute("tests/integration-latest", command + ":emptyfile", function() { - execute("tests/integration-latest", command + ":no-module", function() { - execute("tests/integration-latest", command + ":react", function() { - // - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); - }); -}); - -function execute(dir, cmd, callback) { - - var x = cmd.split(" "); - var runner = spawn(x[0], x.splice(1), { cwd: dir, stdio: "inherit" }); - - runner.on("close", function(code) { - callback(code); - }); -} \ No newline at end of file diff --git a/examples/angular2/.npmrc b/examples/angular2/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/examples/angular2/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/examples/angular2/README.md b/examples/angular2/README.md index 29897689..bd8975a7 100644 --- a/examples/angular2/README.md +++ b/examples/angular2/README.md @@ -6,8 +6,10 @@ Typescript on the fly in Karma with Angular2 and Istanbul coverage. ## Installation ``` -npm install karma-typescript -cd node_modules/karma-typescript/examples/angular2 +git clone https://github.com/monounity/karma-typescript.git +cd karma-typescript +npm run build +cd examples/angular2 npm install ``` @@ -91,4 +93,4 @@ karmaTypescriptConfig: { This software is licensed with the MIT license. -© 2016-2017 Erik Barke, Monounity +© 2016-2018 Erik Barke, Monounity diff --git a/examples/angular2/karma.conf.js b/examples/angular2/karma.conf.js index 6c8ddb4f..e1aba2c2 100644 --- a/examples/angular2/karma.conf.js +++ b/examples/angular2/karma.conf.js @@ -26,6 +26,8 @@ module.exports = function(config) { reporters: ["dots", "karma-typescript"], - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/examples/angular2/package.json b/examples/angular2/package.json index 2ec070ed..4449745d 100644 --- a/examples/angular2/package.json +++ b/examples/angular2/package.json @@ -11,8 +11,6 @@ "private": true, "license": "MIT", "scripts": { - "dev": "gulp dev --cwd . && karma start", - "dev:ci": "gulp dev:ci --cwd . && karma start --browsers ChromeHeadless --single-run", "test": "karma start" }, "dependencies": { @@ -29,13 +27,10 @@ "karma": "^2.0.0", "karma-chrome-launcher": "^2.2.0", "karma-jasmine": "^1.0.2", - "karma-typescript": "../../", + "karma-typescript": "file:../../karma-typescript-3.0.13.tgz", "karma-typescript-angular2-transform": "latest", "rxjs": "^5.3.0", "typescript": "latest", "zone.js": "^0.8.8" - }, - "devDependencies": { - "gulp": "^3.9.1" } } diff --git a/examples/angularjs/.npmrc b/examples/angularjs/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/examples/angularjs/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/examples/angularjs/README.md b/examples/angularjs/README.md index 9a9b648b..82b229df 100644 --- a/examples/angularjs/README.md +++ b/examples/angularjs/README.md @@ -1,11 +1,18 @@ # Runnable example of unit testing Typescript on the fly in Karma with AngularJS and Istanbul coverage -To run the example tests, issue the following commands: +## Installation ``` -npm install karma-typescript -cd node_modules/karma-typescript/examples/angularjs +git clone https://github.com/monounity/karma-typescript.git +cd karma-typescript +npm run build +cd examples/angularjs npm install +``` + +## Running + +``` npm test ``` @@ -15,4 +22,4 @@ The example unit tests should now run in Karma and html test coverage should be This software is licensed with the MIT license. -© 2016-2017 Erik Barke, Monounity +© 2016-2018 Erik Barke, Monounity diff --git a/examples/angularjs/karma.conf.js b/examples/angularjs/karma.conf.js index 5f5c786d..23eac560 100644 --- a/examples/angularjs/karma.conf.js +++ b/examples/angularjs/karma.conf.js @@ -18,6 +18,8 @@ module.exports = function(config) { tsconfig: "./tsconfig.json" }, - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/examples/angularjs/package.json b/examples/angularjs/package.json index f15b77f3..fefc0154 100644 --- a/examples/angularjs/package.json +++ b/examples/angularjs/package.json @@ -11,8 +11,6 @@ "private": true, "license": "MIT", "scripts": { - "dev": "gulp dev --cwd . && karma start", - "dev:ci": "gulp dev:ci --cwd . && karma start --browsers ChromeHeadless --single-run", "test": "karma start" }, "dependencies": { @@ -25,10 +23,7 @@ "karma": "^2.0.0", "karma-chrome-launcher": "^2.2.0", "karma-jasmine": "^1.1.0", - "karma-typescript": "../../", + "karma-typescript": "file:../../karma-typescript-3.0.13.tgz", "typescript": "latest" - }, - "devDependencies": { - "gulp": "^3.9.1" } } diff --git a/examples/docker/.npmrc b/examples/docker/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/examples/docker/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/examples/gulp/.npmrc b/examples/gulp/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/examples/gulp/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/examples/gulp/package.json b/examples/gulp/package.json index 06e5ec80..b1ae0657 100644 --- a/examples/gulp/package.json +++ b/examples/gulp/package.json @@ -14,7 +14,7 @@ "karma": "1.5.0", "karma-jasmine": "^1.0.2", "karma-nyan-reporter": "0.2.4", - "karma-typescript": "../../", + "karma-typescript": "file:../../karma-typescript-3.0.13.tgz", "karma-phantomjs-launcher": "1.0.2", "run-sequence": "1.2.2", "gulp": "3.9.1", diff --git a/examples/mocha/.npmignore b/examples/mocha/.npmignore deleted file mode 100644 index bf3ee2c8..00000000 --- a/examples/mocha/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -coverage -node_modules -npm-debug.log diff --git a/examples/mocha/.npmrc b/examples/mocha/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/examples/mocha/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/examples/mocha/README.md b/examples/mocha/README.md index 51045be7..49dbfe4d 100644 --- a/examples/mocha/README.md +++ b/examples/mocha/README.md @@ -1,11 +1,18 @@ # Runnable example of unit testing Typescript on the fly in Karma with Istanbul coverage and Mocha -To run the example tests, issue the following commands: +## Installation ``` -npm install karma-typescript -cd node_modules/karma-typescript/examples/mocha +git clone https://github.com/monounity/karma-typescript.git +cd karma-typescript +npm run build +cd examples/mocha npm install +``` + +## Running + +``` npm test ``` @@ -15,4 +22,4 @@ The example unit tests should now run in Karma and html test coverage should be This software is licensed with the MIT license. -© 2016-2017 Erik Barke, Monounity +© 2016-2018 Erik Barke, Monounity diff --git a/examples/mocha/karma.conf.js b/examples/mocha/karma.conf.js index 9d2b2224..a2d8c246 100644 --- a/examples/mocha/karma.conf.js +++ b/examples/mocha/karma.conf.js @@ -14,6 +14,8 @@ module.exports = function(config) { reporters: ["dots", "karma-typescript"], - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/examples/mocha/package.json b/examples/mocha/package.json index fbd89bc7..45d3cba1 100644 --- a/examples/mocha/package.json +++ b/examples/mocha/package.json @@ -11,8 +11,6 @@ "private": true, "license": "MIT", "scripts": { - "dev": "gulp dev --cwd . && karma start", - "dev:ci": "gulp dev:ci --cwd . && karma start --browsers ChromeHeadless --single-run", "test": "karma start" }, "dependencies": { @@ -23,11 +21,8 @@ "karma-chrome-launcher": "^2.2.0", "karma-cli": "^1.0.1", "karma-mocha": "^1.3.0", - "karma-typescript": "../../", + "karma-typescript": "file:../../karma-typescript-3.0.13.tgz", "mocha": "^3.1.2", "typescript": "latest" - }, - "devDependencies": { - "gulp": "^3.9.1" } } diff --git a/examples/typescript-1.6.2/.npmrc b/examples/typescript-1.6.2/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/examples/typescript-1.6.2/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/examples/typescript-1.6.2/README.md b/examples/typescript-1.6.2/README.md index 1af641ea..69ee5630 100644 --- a/examples/typescript-1.6.2/README.md +++ b/examples/typescript-1.6.2/README.md @@ -1,11 +1,18 @@ # Runnable example of unit testing Typescript (version 1.6 - 1.7) on the fly in Karma with Istanbul coverage -To run the example tests, issue the following commands: +## Installation ``` -npm install karma-typescript -cd node_modules/karma-typescript/examples/typescript-1.6.2 +git clone https://github.com/monounity/karma-typescript.git +cd karma-typescript +npm run build +cd examples/typescript-1.6.2 npm install +``` + +## Running + +``` npm test ``` @@ -45,4 +52,4 @@ describe('HelloComponent', () => { This software is licensed with the MIT license. -© 2016-2017 Erik Barke, Monounity +© 2016-2018 Erik Barke, Monounity diff --git a/examples/typescript-1.6.2/karma.conf.js b/examples/typescript-1.6.2/karma.conf.js index 07b4835d..716172cf 100644 --- a/examples/typescript-1.6.2/karma.conf.js +++ b/examples/typescript-1.6.2/karma.conf.js @@ -13,6 +13,8 @@ module.exports = function(config) { reporters: ["dots", "karma-typescript"], - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/examples/typescript-1.6.2/package.json b/examples/typescript-1.6.2/package.json index 5eaf3e43..f9a8080c 100644 --- a/examples/typescript-1.6.2/package.json +++ b/examples/typescript-1.6.2/package.json @@ -11,21 +11,16 @@ "private": true, "license": "MIT", "scripts": { - "dev": "gulp dev --cwd . && karma start", - "dev:ci": "gulp dev:ci --cwd . && karma start --browsers ChromeHeadless --single-run", "test": "karma start" }, "dependencies": { "@types/jasmine": "^2.5.35", - "jasmine-core": "^2.4.1", - "karma": "^2.0.0", + "jasmine-core": "^3.2.1", + "karma": "^3.0.0", "karma-chrome-launcher": "^2.2.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", - "karma-typescript": "../../", + "karma-typescript": "file:../../karma-typescript-3.0.13.tgz", "typescript": "1.6.2" - }, - "devDependencies": { - "gulp": "^3.9.1" } } diff --git a/examples/typescript-latest/.npmrc b/examples/typescript-latest/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/examples/typescript-latest/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/examples/typescript-latest/README.md b/examples/typescript-latest/README.md index b89c648d..5caf3a8a 100644 --- a/examples/typescript-latest/README.md +++ b/examples/typescript-latest/README.md @@ -1,11 +1,18 @@ # Runnable example of unit testing Typescript on the fly in Karma with Istanbul coverage -To run the example tests, issue the following commands: +## Installation ``` -npm install karma-typescript -cd node_modules/karma-typescript/examples/typescript-latest +git clone https://github.com/monounity/karma-typescript.git +cd karma-typescript +npm run build +cd examples/typescript-latest npm install +``` + +## Running + +``` npm test ``` @@ -45,4 +52,4 @@ describe('HelloComponent', () => { This software is licensed with the MIT license. -© 2016-2017 Erik Barke, Monounity +© 2016-2018 Erik Barke, Monounity diff --git a/examples/typescript-latest/karma.conf.js b/examples/typescript-latest/karma.conf.js index 07b4835d..716172cf 100644 --- a/examples/typescript-latest/karma.conf.js +++ b/examples/typescript-latest/karma.conf.js @@ -13,6 +13,8 @@ module.exports = function(config) { reporters: ["dots", "karma-typescript"], - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/examples/typescript-latest/package.json b/examples/typescript-latest/package.json index 772f5b50..9f90417a 100644 --- a/examples/typescript-latest/package.json +++ b/examples/typescript-latest/package.json @@ -11,8 +11,6 @@ "private": true, "license": "MIT", "scripts": { - "dev": "gulp dev --cwd . && karma start", - "dev:ci": "gulp dev:ci --cwd . && karma start --browsers ChromeHeadless --single-run", "test": "karma start" }, "dependencies": { @@ -22,10 +20,7 @@ "karma-chrome-launcher": "^2.2.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", - "karma-typescript": "../../", + "karma-typescript": "file:../../karma-typescript-3.0.13.tgz", "typescript": "latest" - }, - "devDependencies": { - "gulp": "^3.9.1" } } diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 7c7c12d6..00000000 --- a/gulpfile.js +++ /dev/null @@ -1,43 +0,0 @@ -var copy = require("copy"), - clear = require("cli-clear"), - del = require("del"), - gulp = require("gulp"), - runSequence = require("run-sequence"), - sourcemaps = require("gulp-sourcemaps"), - ts = require("gulp-typescript"), - tsProject = ts.createProject("../../tsconfig.json"); - -gulp.task("clear", function(cb) { - clear(); - cb(); -}); - -gulp.task("clean", function() { - return del("./coverage"); -}); - -gulp.task("build", function() { - return tsProject.src() - .pipe(sourcemaps.init()) - .pipe(tsProject()) - .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(tsProject.options.outDir)); -}); - -gulp.task("copy", function(cb) { - copy("../../*.js", "./node_modules/karma-typescript/", function() { - copy("../../dist/**/*.js", "./node_modules/karma-typescript/dist/", function() { - copy("../../lib/*.js", "./node_modules/karma-typescript/lib/", function() { - copy("../../src/client/*.js", "./node_modules/karma-typescript/src/client/", function() { - copy("../../transforms/*.js", "./node_modules/karma-typescript/transforms/", cb); - }); - }); - }); - }); -}); - -gulp.task("dev", ["clear", "clean"], function(cb) { - runSequence("build", "copy", cb); -}); - -gulp.task("dev:ci", ["clean", "copy"]); diff --git a/ci/obliterate.sh b/obliterate.sh similarity index 62% rename from ci/obliterate.sh rename to obliterate.sh index 02251ef2..e033d17f 100755 --- a/ci/obliterate.sh +++ b/obliterate.sh @@ -1,12 +1,32 @@ #/bin/sh -cd .. +echo "Cleaning dist" +rm -rf dist/ + +echo "Cleaning node_modules/" rm -rf node_modules/ + +echo "Cleaning examples/angular2/" rm -rf examples/angular2/coverage/ examples/angular2/node_modules/ + +echo "Cleaning examples/angularjs/" rm -rf examples/angularjs/coverage/ examples/angularjs/node_modules/ + +echo "Cleaning examples/gulp/" rm -rf examples/gulp/node_modules/ examples/gulp/src/bar/coverage/ examples/gulp/src/foo/coverage/ + +echo "Cleaning examples/mocha/" rm -rf examples/mocha/coverage/ examples/mocha/node_modules/ + +echo "Cleaning examples/typescript-1.6.2/" rm -rf examples/typescript-1.6.2/coverage/ examples/typescript-1.6.2/node_modules/ + +echo "Cleaning examples/typescript-latest/" rm -rf examples/typescript-latest/coverage/ examples/typescript-latest/node_modules/ + +echo "Cleaning tests/integration-1.8.10/" rm -rf tests/integration-1.8.10/coverage/ tests/integration-1.8.10/node_modules/ + +echo "Cleaning tests/integration-latest/" rm -rf tests/integration-latest/coverage/ tests/integration-latest/node_modules/ +echo "Done" \ No newline at end of file diff --git a/package.json b/package.json index fa9a9737..18823196 100644 --- a/package.json +++ b/package.json @@ -51,12 +51,48 @@ }, "license": "MIT", "scripts": { - "build": "tsc --rootDir ./src", - "build:watch": "tsc -w --rootDir ./src", - "ci": "npm run lint && npm run build && npm run test:unit && npm test", "lint": "eslint ./lib/*.js && tslint --project tsconfig.json", - "test": "node ci/run.js", - "test:unit": "tape dist/**/*.spec.js | faucet" + "build": "tsc --rootDir ./src && npm pack", + "test": "npm run test:unit && npm run test:examples && npm run test:integration", + "test:examples": "npm run test:examples:angular2 && npm run test:examples:angularjs && npm run test:examples:mocha && npm run test:examples:typescript-1.6.2 && npm run test:examples:typescript-latest", + "test:integration": "npm run test:tests:integration-1.8.10 && npm run test:tests:integration-latest", + "test:unit": "tape dist/**/*.spec.js | faucet", + "ci": "npm run lint && npm test", + "dev": "npm run lint && npm run build && npm run setup:kt && npm test", + "setup": "npm i && npm run build && npm run setup:examples && npm run setup:tests", + "setup:examples": "npm run setup:examples:angular2 && npm run setup:examples:angularjs && npm run setup:examples:mocha && npm run setup:examples:typescript-1.6.2 && npm run setup:examples:typescript-1.6.2 && npm run setup:examples:typescript-latest", + "setup:tests": "npm run setup:tests:integration-1.8.10 && npm run setup:tests:integration-latest", + "setup:kt": "npm run setup:kt:examples && npm run setup:kt:tests", + "setup:kt:examples": "npm run setup:kt:examples:angular2 && npm run setup:kt:examples:angularjs && npm run setup:kt:examples:mocha && npm run setup:kt:examples:typescript-1.6.2 && npm run setup:kt:examples:typescript-1.6.2 && npm run setup:kt:examples:typescript-latest", + "setup:kt:tests": "npm run setup:kt:tests:integration-1.8.10 && npm run setup:kt:tests:integration-latest", + "setup:examples:angular2": "cd examples/angular2 && npm install && cd ../..", + "setup:kt:examples:angular2": "npm --prefix examples/angular2 install karma-typescript-3.0.13.tgz", + "test:examples:angular2": "npm --prefix examples/angular2 test", + "dev:examples:angular2": "npm run build && npm run setup:kt:examples:angular2 && npm run test:examples:angular2", + "setup:examples:angularjs": "cd examples/angularjs && npm install && cd ../..", + "setup:kt:examples:angularjs": "npm --prefix examples/angularjs install karma-typescript-3.0.13.tgz", + "test:examples:angularjs": "npm --prefix examples/angularjs test", + "dev:examples:angularjs": "npm run build && npm run setup:kt:examples:angularjs && npm run test:examples:angularjs", + "setup:examples:mocha": "cd examples/mocha && npm install && cd ../..", + "setup:kt:examples:mocha": "npm --prefix examples/mocha install karma-typescript-3.0.13.tgz", + "test:examples:mocha": "npm --prefix examples/mocha test", + "dev:examples:mocha": "npm run build && npm run setup:kt:examples:mocha && npm run test:examples:mocha", + "setup:examples:typescript-1.6.2": "cd examples/typescript-1.6.2 && npm install && cd ../..", + "setup:kt:examples:typescript-1.6.2": "npm --prefix examples/typescript-1.6.2 install karma-typescript-3.0.13.tgz", + "test:examples:typescript-1.6.2": "npm --prefix examples/typescript-1.6.2 test", + "dev:examples:typescript-1.6.2": "npm run build && npm run setup:kt:examples:typescript-1.6.2 && npm run test:examples:typescript-1.6.2", + "setup:examples:typescript-latest": "cd examples/typescript-latest && npm install && cd ../..", + "setup:kt:examples:typescript-latest": "npm --prefix examples/typescript-latest karma-typescript-3.0.13.tgz", + "test:examples:typescript-latest": "npm --prefix examples/typescript-latest test", + "dev:examples:typescript-latest": "npm run build && npm run setup:kt:examples:typescript-latest && npm run test:examples:typescript-latest", + "setup:tests:integration-1.8.10": "cd tests/integration-1.8.10 && npm install && cd ../..", + "setup:kt:tests:integration-1.8.10": "npm --prefix tests/integration-1.8.10 install karma-typescript-3.0.13.tgz", + "test:tests:integration-1.8.10": "npm --prefix tests/integration-1.8.10 test && npm --prefix tests/integration-1.8.10 run test:angular2 && npm --prefix tests/integration-1.8.10 run test:react", + "dev:tests:integration-1.8.10": "npm run build && npm run setup:kt:tests:integration-1.8.10 && npm run test:tests:integration-1.8.10", + "setup:tests:integration-latest": "cd tests/integration-latest && npm install && cd ../..", + "setup:kt:tests:integration-latest": "npm --prefix tests/integration-latest install karma-typescript-3.0.13.tgz", + "test:tests:integration-latest": "npm --prefix tests/integration-latest test && npm --prefix tests/integration-latest run test:angular2 && npm --prefix tests/integration-latest run test:core && npm --prefix tests/integration-latest run test:emptyfile && npm --prefix tests/integration-latest run test:no-module && npm --prefix tests/integration-latest run test:react", + "dev:tests:integration-latest": "npm run build && npm run setup:kt:tests:integration-latest && npm run test:tests:integration-latest" }, "dependencies": { "acorn": "^4.0.4", @@ -120,26 +156,19 @@ "@types/tape": "^4.2.29", "@types/tmp": "0.0.32", "cli-clear": "^1.0.4", - "copy": "^0.3.0", - "cross-spawn": "^5.1.0", - "del": "^2.2.2", "eslint": "^3.4.0", "faucet": "0.0.1", - "gulp": "^3.9.1", - "gulp-sourcemaps": "^2.6.1", - "gulp-typescript": "^3.2.3", "mock-require": "^2.0.2", "puppeteer": "^1.1.1", - "run-sequence": "^2.2.0", "sinon": "^2.1.0", "tape": "^4.6.3", "tslint": "^4.4.2", "tslint-eslint-rules": "^3.3.0", - "typescript": "^3.1.1" + "typescript": "latest" }, "peerDependencies": { "karma": "1 || 2 || 3", - "typescript": "2 || 3" + "typescript": "1 || 2 || 3" }, "collective": { "type": "opencollective", diff --git a/src/bundler/bundler.ts b/src/bundler/bundler.ts index 54bc32d0..b055ed50 100644 --- a/src/bundler/bundler.ts +++ b/src/bundler/bundler.ts @@ -23,6 +23,8 @@ import { Resolver } from "./resolve/resolver"; import { Transformer } from "./transformer"; import { Validator } from "./validator"; +import "../client/commonjs"; + export class Bundler { private readonly BUNDLE_DELAY = 500; @@ -59,7 +61,7 @@ export class Bundler { files.push({ included: true, - pattern: path.join(__dirname, "../../src/client/commonjs.js"), + pattern: path.join(__dirname, "../../dist/client/commonjs.js"), served: true, watched: false }); diff --git a/src/client/commonjs.js b/src/client/commonjs.ts similarity index 58% rename from src/client/commonjs.js rename to src/client/commonjs.ts index cbae2b0d..dce45554 100644 --- a/src/client/commonjs.js +++ b/src/client/commonjs.ts @@ -1,34 +1,34 @@ -(function(global) { +((global) => { "use strict"; global.__karmaTypescriptModules__ = {}; - var fn = 0, - id = 1, - map = 2; - function require(filename, requiring, required) { - var wrapper, - module = global.__karmaTypescriptModules__ [filename]; + const fn = 0; + const id = 1; + const map = 2; + const require = (filename: any, requiring: any, required: any) => { + let wrapper: any; + let module = global.__karmaTypescriptModules__ [filename]; if (!module) { wrapper = global.wrappers[filename]; - if(!wrapper) { + if (!wrapper) { throw new Error("Can't find " + required + " [" + filename + "] (required by " + requiring + ")"); } module = { exports: {}, id: wrapper[id], uri: filename }; global.__karmaTypescriptModules__ [filename] = module; - wrapper[fn].call(module.exports, function (dependency) { + wrapper[fn].call(module.exports, (dependency: any) => { return require(wrapper[map][dependency], filename, dependency); }, module, module.exports, filename.slice(0, filename.lastIndexOf("/")), filename); - if(module.exports && !module.exports.default && isExtensible(module.exports)) { + if (module.exports && !module.exports.default && isExtensible(module.exports)) { Object.defineProperty(module.exports, "default", { - enumerable: false, configurable: true, writable: true, value: module.exports + configurable: true, enumerable: false, value: module.exports, writable: true }); } } return module.exports; - } - function isExtensible(obj) { + }; + const isExtensible = (obj: any) => { return (typeof obj === "function" || typeof obj === "object") && Object.isExtensible(obj); - } - (global.entrypointFilenames || []).forEach(function(filename) { + }; + (global.entrypointFilenames || []).forEach((filename: any) => { require(filename, "commonjs.js", "entrypoint"); }); })(this); diff --git a/tests/integration-1.8.10/.npmrc b/tests/integration-1.8.10/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/tests/integration-1.8.10/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/tests/integration-1.8.10/README.md b/tests/integration-1.8.10/README.md index a4f1b9df..4f3c6d45 100644 --- a/tests/integration-1.8.10/README.md +++ b/tests/integration-1.8.10/README.md @@ -1,12 +1,16 @@ -# Integration tests for Typescript 1.8.10 +# Integration tests for Typescript@1.8.10 -This project contains a suite of integration tests that uses the `karma-typescript` plugin itself to test the its functionality. +This project contains integration tests that uses the `karma-typescript` plugin itself to test the its functionality. +The project isn't actively maintained, it only exists for historical reasons to make sure projects using Typescript@1.8.10 don't break. -* `npm test`, runs all tests with Chrome and watches for changes +## Test suites -Each `dev` tests deletes the coverage folder and copies the `karma-typescript` source code to the `node_modules` folder. +* `npm run test` - Main test suite for testing frameworks, performance etc. +* `npm run test:angular2` - A targeted test suite for testing code using the Angular2 framework. Also included in the main test suite. +* `npm run test:react` - A targeted test suite for testing code using the React framework. Also included in the main test suite. -* `npm run dev`, runs all tests and watches for changes -* `npm run dev:ci`, runs all tests once (continous integration) -* `npm run dev:ci:angular2`, runs the Angular2 tests once (continous integration) -* `npm run dev:ci:react`, runs the React tests once (continous integration) +## Licensing + +This software is licensed with the MIT license. + +© 2016-2018 Erik Barke, Monounity diff --git a/tests/integration-1.8.10/karma.conf.angular2.js b/tests/integration-1.8.10/karma.conf.angular2.js index 734afc6e..49318c8e 100644 --- a/tests/integration-1.8.10/karma.conf.angular2.js +++ b/tests/integration-1.8.10/karma.conf.angular2.js @@ -30,6 +30,8 @@ module.exports = function(config) { reporters: ["dots", "karma-typescript"], - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/tests/integration-1.8.10/karma.conf.js b/tests/integration-1.8.10/karma.conf.js index 8d059f40..32e4e491 100644 --- a/tests/integration-1.8.10/karma.conf.js +++ b/tests/integration-1.8.10/karma.conf.js @@ -31,6 +31,8 @@ module.exports = function(config) { browserNoActivityTimeout : 60000, - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/tests/integration-1.8.10/karma.conf.react.js b/tests/integration-1.8.10/karma.conf.react.js index c62837fc..3e9bf587 100644 --- a/tests/integration-1.8.10/karma.conf.react.js +++ b/tests/integration-1.8.10/karma.conf.react.js @@ -22,6 +22,8 @@ module.exports = function(config) { reporters: ["dots", "karma-typescript"], - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/tests/integration-1.8.10/package.json b/tests/integration-1.8.10/package.json index 62332868..78ba9e57 100644 --- a/tests/integration-1.8.10/package.json +++ b/tests/integration-1.8.10/package.json @@ -11,11 +11,9 @@ "private": true, "license": "MIT", "scripts": { - "dev": "gulp dev --cwd . && karma start", - "dev:ci": "gulp dev:ci --cwd . && karma start --browsers ChromeHeadless --single-run", - "dev:ci:angular2": "gulp dev:ci --cwd . && karma start karma.conf.angular2.js --browsers ChromeHeadless --single-run", - "dev:ci:react": "gulp dev:ci --cwd . && karma start karma.conf.react.js --browsers ChromeHeadless --single-run", - "test": "karma start" + "test": "karma start", + "test:angular2": "karma start karma.conf.angular2.js", + "test:react": "karma start karma.conf.react.js" }, "dependencies": { "@angular/common": "2.0.1", @@ -30,7 +28,7 @@ "karma-chrome-launcher": "^2.2.0", "karma-cli": "1.0.1", "karma-jasmine": "1.0.2", - "karma-typescript": "../../", + "karma-typescript": "file:../../karma-typescript-3.0.13.tgz", "react": "15.3.2", "react-addons-test-utils": "15.3.2", "react-dom": "15.3.2", @@ -39,8 +37,5 @@ "sinon": "1.17.6", "typescript": "1.8.10", "zone.js": "0.6.25" - }, - "devDependencies": { - "gulp": "^3.9.1" } } diff --git a/tests/integration-latest/.npmrc b/tests/integration-latest/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/tests/integration-latest/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/tests/integration-latest/README.md b/tests/integration-latest/README.md index 7827b519..3894b804 100644 --- a/tests/integration-latest/README.md +++ b/tests/integration-latest/README.md @@ -1,15 +1,43 @@ -# Integration tests for Typescript 2.x +# Integration tests for Typescript@latest -This project contains a suite of integration tests that uses the `karma-typescript` plugin itself to test the its functionality. +This project contains integration tests that uses the `karma-typescript` plugin itself to test the its functionality. The project is a 'living' project: the intention is that it should keep up with the latest version of Typescript and new tests should be added to it describing bug fixes or new features. -* `npm test`, runs all tests with Chrome and watches for changes +## Developing +After making changes to the source code or a test, and before running any tests, `karma-typescript` needs to be rebuilt and reinstalled to make sure the tests are running the latest local version of the source code. A convenient way to build, install and test the latest local code is to use the scripts in the `package.json` in the root of the `karma-typescript` project, which contains scripts for building, installing and running the test suites. -Each `dev` tests deletes the coverage folder and copies the `karma-typescript` source code to the `node_modules` folder. +From the root of the `karma-typescript` project, run the following commands to build and install a fresh local version: +* `npm run build` - Transpile and pack the latest local `karma-typescript` Typescript source code. +* `npm run setup:kt:tests:integration-latest` - Install the latest local build to this project. -* `npm run dev`, runs all tests and watches for changes -* `npm run dev:ci`, runs all tests once (continous integration) -* `npm run dev:ci:angular2`, runs the Angular2 tests once (continous integration) -* `npm run dev:ci:core`, runs the core tests once (continous integration) -* `npm run dev:ci:emptyfile`, runs the empty file tests once (continous integration) -* `npm run dev:ci:no-module`, runs the no module tests once (continous integration) -* `npm run dev:ci:react`, runs the React tests once (continous integration) +After building and installing the latest local build, run one of the following test suites: + +* `npm run test` - Main test suite for testing bundling, frameworks, imports, performance etc. This is probably where new tests describing bugs or new features will be added. +* `npm run test:angular2` - A targeted test suite for testing code using the Angular2 framework. Also included in the main test suite. +* `npm run test:core` - A separate test suite for testing Node.js core features. Not included in the main test suite. +* `npm run test:emptyfile` - A separate test suite testing instrumentation of empty output, reported in issue #26. Not included in the main test suite. +* `npm run test:no-module` - A targeted test suite for testing code not using modules. Also included in the main test suite. +* `npm run test:react` - A targeted test suite for testing code using the React framework. Also included in the main test suite. + +To run a test suite from the root of the `karma-typescript` project, simply add a prefix to tell `npm` to run from the root of this project, for example: + +`npm run --prefix tests/integration-latest test:react `. + +To make life easier when developing, these commands can be combined: + +`npm run build && npm run setup:kt:tests:integration-latest && npm run --prefix tests/integration-latest test:react` + +## Debugging tests + +All of the tests suites can be run in debug mode, ie using a regular Chrome browser instead of the Chrome Headless browser. To run a test suite in debug mode, just add the suffix `:debug` to the script name, for example `npm run test:debug` or `npm run test:react:debug`. + +Putting it all together: + +`npm run build && npm run setup:kt:tests:integration-latest && npm run --prefix tests/integration-latest test:react:debug` + +Happy contributing! + +## Licensing + +This software is licensed with the MIT license. + +© 2016-2018 Erik Barke, Monounity diff --git a/tests/integration-latest/karma.conf.angular2.js b/tests/integration-latest/karma.conf.angular2.js index f3bcfdd0..a54021e6 100644 --- a/tests/integration-latest/karma.conf.angular2.js +++ b/tests/integration-latest/karma.conf.angular2.js @@ -39,6 +39,8 @@ module.exports = function(config) { reporters: ["dots", "karma-typescript"], - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/tests/integration-latest/karma.conf.core.js b/tests/integration-latest/karma.conf.core.js index a2569a73..6a9c6b9a 100644 --- a/tests/integration-latest/karma.conf.core.js +++ b/tests/integration-latest/karma.conf.core.js @@ -30,6 +30,8 @@ module.exports = function(config) { reporters: ["dots", "karma-typescript"], - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/tests/integration-latest/karma.conf.emptyfile.js b/tests/integration-latest/karma.conf.emptyfile.js index 79985e65..89823c37 100644 --- a/tests/integration-latest/karma.conf.emptyfile.js +++ b/tests/integration-latest/karma.conf.emptyfile.js @@ -23,6 +23,8 @@ module.exports = function(config) { reporters: ["dots", "karma-typescript"], - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/tests/integration-latest/karma.conf.js b/tests/integration-latest/karma.conf.js index e4ccef38..389ec70a 100644 --- a/tests/integration-latest/karma.conf.js +++ b/tests/integration-latest/karma.conf.js @@ -139,6 +139,8 @@ module.exports = function(config) { browserNoActivityTimeout : 60000, - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/tests/integration-latest/karma.conf.no.module.js b/tests/integration-latest/karma.conf.no.module.js index decd64c3..5f3a6247 100644 --- a/tests/integration-latest/karma.conf.no.module.js +++ b/tests/integration-latest/karma.conf.no.module.js @@ -28,6 +28,8 @@ module.exports = function(config) { reporters: ["dots", "karma-typescript"], - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/tests/integration-latest/karma.conf.react.js b/tests/integration-latest/karma.conf.react.js index 174a1a18..2fa31819 100644 --- a/tests/integration-latest/karma.conf.react.js +++ b/tests/integration-latest/karma.conf.react.js @@ -32,6 +32,8 @@ module.exports = function(config) { reporters: ["dots", "karma-typescript"], - browsers: ["Chrome"] + browsers: ["ChromeHeadless"], + + singleRun: true }); }; diff --git a/tests/integration-latest/package.json b/tests/integration-latest/package.json index b8b2eeb0..8bb30f2e 100644 --- a/tests/integration-latest/package.json +++ b/tests/integration-latest/package.json @@ -11,15 +11,19 @@ "private": true, "license": "MIT", "scripts": { - "dev": "gulp dev --cwd . && karma start", - "dev:ci": "gulp dev:ci --cwd . && karma start --browsers ChromeHeadless --single-run", - "dev:ci:angular2": "gulp dev:ci --cwd . && karma start karma.conf.angular2.js --browsers ChromeHeadless --single-run", - "dev:ci:core": "gulp dev:ci --cwd . && karma start karma.conf.core.js --browsers ChromeHeadless --single-run", - "dev:ci:emptyfile": "gulp dev:ci --cwd . && karma start karma.conf.emptyfile.js --browsers ChromeHeadless --single-run", - "dev:ci:no-module": "gulp dev:ci --cwd . && karma start karma.conf.no.module.js --browsers ChromeHeadless --single-run", - "dev:ci:react": "gulp dev:ci --cwd . && karma start karma.conf.react.js --browsers ChromeHeadless --single-run", "prepare": "bower install", - "test": "karma start" + "test": "karma start", + "test:debug": "karma start --browsers Chrome --no-single-run", + "test:angular2": "karma start karma.conf.angular2.js", + "test:angular2:debug": "karma start karma.conf.angular2.js --browsers Chrome --no-single-run", + "test:core": "karma start karma.conf.core.js", + "test:core:debug": "karma start karma.conf.core.js --browsers Chrome --no-single-run", + "test:emptyfile": "karma start karma.conf.emptyfile.js", + "test:emptyfile:debug": "karma start karma.conf.emptyfile.js --browsers Chrome --no-single-run", + "test:no-module": "karma start karma.conf.no.module.js", + "test:no-module:debug": "karma start karma.conf.no.module.js --browsers Chrome --no-single-run", + "test:react": "karma start karma.conf.react.js", + "test:react:debug": "karma start karma.conf.react.js --browsers Chrome --no-single-run" }, "dependencies": { "@angular/common": "^4.2.3", @@ -62,7 +66,7 @@ "karma-chrome-launcher": "^2.2.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", - "karma-typescript": "../../", + "karma-typescript": "file:../../karma-typescript-3.0.13.tgz", "karma-typescript-cssmodules-transform": "latest", "karma-typescript-es6-transform": "latest", "karma-typescript-postcss-transform": "latest", @@ -86,7 +90,6 @@ "zone.js": "^0.8.8" }, "devDependencies": { - "bower": "^1.8.0", - "gulp": "^3.9.1" + "bower": "^1.8.0" } }