From 3b344a838343ba037a6c41cbec22d112bfb3dcdd Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 25 Jul 2016 20:34:34 -0700 Subject: [PATCH] Moved build process to gulp-shenanigans --- .gitignore | 6 +++- gulpfile.js | 57 ++---------------------------- package.json | 14 ++------ test/StringFilr/_.ts | 7 ++++ test/tsconfig.json | 11 ++++++ test/unit/StringFilrTests/_.js | 9 ----- test/unit/index.html | 18 ---------- test/unit/mocks.js | 20 ----------- test/unit/phantom.js | 1 - test/unit/require.js | 5 --- test/unit/unit.js | 63 ---------------------------------- test/utils/mocks.ts | 11 ++++++ tsconfig.json | 5 +-- 13 files changed, 42 insertions(+), 185 deletions(-) create mode 100644 test/StringFilr/_.ts create mode 100644 test/tsconfig.json delete mode 100644 test/unit/StringFilrTests/_.js delete mode 100644 test/unit/index.html delete mode 100644 test/unit/mocks.js delete mode 100644 test/unit/phantom.js delete mode 100644 test/unit/require.js delete mode 100644 test/unit/unit.js create mode 100644 test/utils/mocks.ts diff --git a/.gitignore b/.gitignore index e81a66d..a545ce5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ -dist/** +lib/** src/**/*.js* +test/**/*.js +test/index.html +test/utils/** +!test/utils/mocks.ts node_modules/ npm-debug.log diff --git a/gulpfile.js b/gulpfile.js index 62b7545..611b915 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,55 +1,4 @@ -const gulp = require("gulp"); -const merge = require("merge2"); -const mochaPhantomJS = require("gulp-mocha-phantomjs"); -const runSequence = require("run-sequence"); -const ts = require("gulp-typescript"); -const tslint = require("gulp-tslint"); - -gulp.task("tslint", () => { - return gulp - .src(["src/**/*.ts", "!src/**/*.d.ts"]) - .pipe(tslint()) - .pipe(tslint.report("verbose")); -}); - -gulp.task("tsc", () => { - const tsProject = ts.createProject("tsconfig.json"); - - return tsProject - .src() - .pipe(ts(tsProject)) - .js.pipe(gulp.dest("src")); -}); - -gulp.task("test", () => { - return gulp - .src("test/unit/index.html") - .pipe(mochaPhantomJS()); - -}); - -gulp.task("dist", function() { - const tsProject = ts.createProject( - "tsconfig.json", - { - outFile: "dist/StringFilr.js", - removeComments: true - }); - - const tsResult = tsProject - .src() - .pipe(ts(tsProject)); - - return merge([ - tsResult.dts.pipe(gulp.dest("dist")), - tsResult.js.pipe(gulp.dest("dist")) - ]); -}); - -gulp.task("watch", ["default"], () => { - gulp.watch("src/**/*.ts", ["default"]); -}); - -gulp.task("default", ["tsc", "tslint", "dist"], cb => { - runSequence(["test"], cb); +require("gulp-shenanigans").initialize({ + gulp: require("gulp"), + packageName: "StringFilr" }); diff --git a/package.json b/package.json index ca4af0b..188350a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "stringfilr", "description": "A path-based cache for quick loops in nested data structures.", - "version": "0.4.0", + "version": "0.5.0", "author": { "name": "Josh Goldberg", "email": "josh@fullscreenmario.com" @@ -15,16 +15,6 @@ }, "license": "MIT", "devDependencies": { - "chai": "^3.5.0", - "gulp": "^3.9.1", - "gulp-mocha-phantomjs": "^0.11.0", - "gulp-tslint": "^5.0.0", - "gulp-typescript": "^2.13.4", - "merge2": "^1.0.2", - "mocha": "^2.4.5", - "requirejs": "^2.2.0", - "run-sequence": "^1.2.0", - "tslint": "^3.10.2", - "typescript": "^1.8.10" + "gulp-shenanigans": "^0.3.1" } } diff --git a/test/StringFilr/_.ts b/test/StringFilr/_.ts new file mode 100644 index 0000000..3148f08 --- /dev/null +++ b/test/StringFilr/_.ts @@ -0,0 +1,7 @@ +/// +/// +/// +/// +/// + +mochaLoader.addTest("_", (): void => { }); diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000..ec96195 --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "es3", + "declaration": false + }, + "files": [ + "utils/mocks.ts", + "utils/MochaLoader.ts", + "StringFilr/_.ts" + ] +} \ No newline at end of file diff --git a/test/unit/StringFilrTests/_.js b/test/unit/StringFilrTests/_.js deleted file mode 100644 index e5d237b..0000000 --- a/test/unit/StringFilrTests/_.js +++ /dev/null @@ -1,9 +0,0 @@ -define(["mocks"], function (mocks) { - return function () { - var expect = require("chai").expect; - - it("tests haven't been implemented", function () { - // ... - }); - }; -}); \ No newline at end of file diff --git a/test/unit/index.html b/test/unit/index.html deleted file mode 100644 index f12d76a..0000000 --- a/test/unit/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - EightBittr Unit Tests - - - - - -
- - - - - - - - \ No newline at end of file diff --git a/test/unit/mocks.js b/test/unit/mocks.js deleted file mode 100644 index 4c41f61..0000000 --- a/test/unit/mocks.js +++ /dev/null @@ -1,20 +0,0 @@ -define(["StringFilr"], function (StringFilrModule) { - var StringFilr = StringFilrModule.StringFilr; - - var mocks = { - /** - * - */ - mockItemValue: function (settings) { - return new ItemValue(settings) - }, - /** - * - */ - mockStringFilr: function (settings) { - return new StringFilr(settings) - } - }; - - return mocks; -}); diff --git a/test/unit/phantom.js b/test/unit/phantom.js deleted file mode 100644 index 7788750..0000000 --- a/test/unit/phantom.js +++ /dev/null @@ -1 +0,0 @@ -require(["unit"]); diff --git a/test/unit/require.js b/test/unit/require.js deleted file mode 100644 index 93cfe5a..0000000 --- a/test/unit/require.js +++ /dev/null @@ -1,5 +0,0 @@ -require( - ["unit"], - function () { - mocha.run(); - }); diff --git a/test/unit/unit.js b/test/unit/unit.js deleted file mode 100644 index 1acc31d..0000000 --- a/test/unit/unit.js +++ /dev/null @@ -1,63 +0,0 @@ -var sources = (function () { - var config = { - paths: { - // Source code - "StringFilr": "../../src/StringFilr", - // External libraries - "chai": "../../node_modules/chai/chai" - } - }; - - requirejs.config(config); - - return Object.keys(config.paths).concat("mocks"); -})(); - -var tests = { - "StringFilr": [ - "_" - ] -}; - -require(sources, function () { - var classTests = {}; - var requiredTests = 0; - var loadedTests = 0; - - var runTests = function () { - mocha.setup("bdd"); - - for (var className in classTests) { - describe(className, function () { - for (var functionName in classTests[className]) { - describe(functionName, classTests[className][functionName]); - } - }); - } - - mocha.run(); - }; - - var generateOnTestLoad = function (className, functionName) { - requiredTests += 1; - - return function (functionTests) { - classTests[className][functionName] = functionTests; - loadedTests += 1; - - if (loadedTests === requiredTests) { - runTests(); - } - } - } - - for (var className in tests) { - classTests[className] = {}; - - tests[className].forEach(function (functionName) { - require( - [className + "Tests/" + functionName], - generateOnTestLoad(className, functionName)); - }); - } -}); \ No newline at end of file diff --git a/test/utils/mocks.ts b/test/utils/mocks.ts new file mode 100644 index 0000000..29ffee1 --- /dev/null +++ b/test/utils/mocks.ts @@ -0,0 +1,11 @@ +/// + +const mocks = { + /** + * @param settings Settings for the StringFilr. + * @returns An StringFilr instance. + */ + mockStringFilr: (settings?: StringFilr.IStringFilrSettings): StringFilr.IStringFilr => { + return new StringFilr.StringFilr(settings); + } +}; diff --git a/tsconfig.json b/tsconfig.json index 3660126..1c5f8ca 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,8 @@ "declaration": true, "outDir": "dist" }, - "exclude": [ - "node_modules" + "files": [ + "src/IStringFilr.ts", + "src/StringFilr.ts" ] } \ No newline at end of file