From b80c1f90903669b017c28b2f5d43ec86566d4620 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Fri, 1 Jul 2016 04:50:23 +0200 Subject: [PATCH] ready for primetime --- .gitignore | 11 +---------- README.md | 3 +-- assets/node-shebang.js | 1 - dist/cli.js | 2 ++ dist/npmts.compile.js | 26 +++++++++++++++++++++----- package.json | 14 ++++++++------ ts/npmts.compile.ts | 28 +++++++++++++++++++++------- 7 files changed, 54 insertions(+), 31 deletions(-) delete mode 100644 assets/node-shebang.js create mode 100644 dist/cli.js diff --git a/.gitignore b/.gitignore index 38bf84d..cfadf59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,4 @@ -.idea/ -.c9/ node_modules/ -test/assets/**/node_modules/ -test/assets/**/docs/ -test/assets/**/typings/ -test/assets/**/coverage/ -ts/*.js -ts/*.js.map -ts/typings/ +test/ docs/ - .DS_Store \ No newline at end of file diff --git a/README.md b/README.md index bca5743..37cf095 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,7 @@ Then add it to your package.json's script section to trigger a build: 1. Check config in ./npmts.json 1. Clean up from any previous builds (old js files) 1. Install typings -1. Transpile TypeScript with inline sourcemaps -1. Create Declaration Files +1. Transpile TypeScript with **inline sourcemaps** and **declaration files** 1. Create JsDoc Documentation 1. Instrumentalize created JavaScript files with istanbul 1. Run Tests diff --git a/assets/node-shebang.js b/assets/node-shebang.js deleted file mode 100644 index 908ba84..0000000 --- a/assets/node-shebang.js +++ /dev/null @@ -1 +0,0 @@ -#!/usr/bin/env node diff --git a/dist/cli.js b/dist/cli.js new file mode 100644 index 0000000..9ab44a7 --- /dev/null +++ b/dist/cli.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +var index = require("./index.js"); \ No newline at end of file diff --git a/dist/npmts.compile.js b/dist/npmts.compile.js index 7e2de84..6a58100 100644 --- a/dist/npmts.compile.js +++ b/dist/npmts.compile.js @@ -3,6 +3,7 @@ require("typings-global"); var plugins = require("./npmts.plugins"); var helpers = require("./npmts.compile.helpers"); var npmts_promisechain_1 = require("./npmts.promisechain"); +var promiseArray = []; var compileTs = function (tsFileArrayArg, tsOptionsArg) { if (tsOptionsArg === void 0) { tsOptionsArg = {}; } var done = plugins.Q.defer(); @@ -17,12 +18,25 @@ var compileTs = function (tsFileArrayArg, tsOptionsArg) { var tsOptions = function (keyArg) { return plugins.lodashObject.assign(tsOptionsDefault, tsOptionsArg); }; - for (var keyArg in tsFileArrayArg) { + var _loop_1 = function(keyArg) { + plugins.beautylog.info("TypeScript assignment: transpile from " + keyArg.blue + " to " + tsFileArrayArg[keyArg].blue); if (helpers.checkOutputPath(tsFileArrayArg, keyArg)) { - var filesToConvert = plugins.smartfile.fs.listFileTree(plugins.path.resolve(keyArg), "**/*.ts"); - plugins.tsn.compile(filesToConvert, tsFileArrayArg[keyArg]); + var filesReadPromise = plugins.smartfile.fs.listFileTree(process.cwd(), keyArg) + .then(function (filesToConvertArg) { + var filesToConvertAbsolute = plugins.smartpath.transform.toAbsolute(filesToConvertArg, process.cwd()); + var destDir = plugins.smartpath.transform.toAbsolute(tsFileArrayArg[keyArg], process.cwd()); + var filesCompiledPromise = plugins.tsn.compile(filesToConvertAbsolute, destDir); + promiseArray.push(filesCompiledPromise); + }); + promiseArray.push(filesReadPromise); } + }; + for (var keyArg in tsFileArrayArg) { + _loop_1(keyArg); } + ; + plugins.Q.all(promiseArray) + .then(done.resolve); return done.promise; }; exports.run = function (configArg) { @@ -31,10 +45,12 @@ exports.run = function (configArg) { npmts_promisechain_1.npmtsOra.text("now compiling " + "TypeScript".yellow); compileTs(config.ts, config.tsOptions) .then(function () { - compileTs(config.testTs); + plugins.beautylog.ok("compiled main TypeScript!"); + plugins.beautylog.log("now compiling tests!"); + return compileTs(config.testTs); }) .then(function () { - plugins.beautylog.ok("compiled TypeScript!"); + plugins.beautylog.ok("compiled all TypeScript!"); done.resolve(config); }); return done.promise; diff --git a/package.json b/package.json index a2afdfe..4b67265 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,13 @@ "npmts": "dist/cli.js" }, "scripts": { - "test": "(npm run compile && npm run check && npm run checkVersion && npm run checkNoTest)", - "check": "(cd ./test/assets && node ../../dist/index.js)", - "checkVersion": "cd ./test/assets && node ../../dist/index.js -v", - "checkNoTest": "cd ./test/assets && node ../../dist/index.js --notest", - "compile": "(tsc)" + "test": "(npm run compile && npm run setupCheck && npm run check && npm run checkVersion && npm run checkNoTest)", + "compile": "(rm -rf test/ && rm -r dist/ && mkdir dist/ && tsc && cp assets/cli.js dist/ )", + "setupCheck":"(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)", + "check": "(cd test && node ../dist/index.js)", + "checkVersion": "(cd test/ && node ../dist/index.js -v)", + "checkNoTest": "(cd test && node ../dist/index.js --notest)", + "install":"(mkdir test/)" }, "repository": { "type": "git", @@ -54,7 +56,7 @@ "smartpath": "3.2.2", "smartstring": "^2.0.10", "source-map-support": "^0.4.1", - "tsn": "^1.0.1", + "tsn": "^1.0.3", "typescript": "^2.0.0-dev.20160630", "typings-global": "*" }, diff --git a/ts/npmts.compile.ts b/ts/npmts.compile.ts index d1955b2..b77624c 100644 --- a/ts/npmts.compile.ts +++ b/ts/npmts.compile.ts @@ -4,7 +4,8 @@ import paths = require("./npmts.paths"); import helpers = require("./npmts.compile.helpers"); import {npmtsOra} from "./npmts.promisechain"; -let compileTs = (tsFileArrayArg,tsOptionsArg = {}) => { +let promiseArray = []; +let compileTs = (tsFileArrayArg:string[],tsOptionsArg = {}) => { let done = plugins.Q.defer(); let tsOptionsDefault = { @@ -20,11 +21,23 @@ let compileTs = (tsFileArrayArg,tsOptionsArg = {}) => { return plugins.lodashObject.assign(tsOptionsDefault, tsOptionsArg) }; for (let keyArg in tsFileArrayArg) { + plugins.beautylog.info(`TypeScript assignment: transpile from ${keyArg.blue} to ${tsFileArrayArg[keyArg].blue}`); if (helpers.checkOutputPath(tsFileArrayArg,keyArg)) { - let filesToConvert = plugins.smartfile.fs.listFileTree(plugins.path.resolve(keyArg),"**/*.ts"); - plugins.tsn.compile(filesToConvert,tsFileArrayArg[keyArg]); + let filesReadPromise = plugins.smartfile.fs.listFileTree(process.cwd(),keyArg) + .then((filesToConvertArg) => { + let filesToConvertAbsolute = plugins.smartpath.transform.toAbsolute(filesToConvertArg,process.cwd()); + let destDir = plugins.smartpath.transform.toAbsolute(tsFileArrayArg[keyArg],process.cwd()); + let filesCompiledPromise = plugins.tsn.compile( + filesToConvertAbsolute, + destDir + ); + promiseArray.push(filesCompiledPromise); + }); + promiseArray.push(filesReadPromise); } - } + }; + plugins.Q.all(promiseArray) + .then(done.resolve); return done.promise; } @@ -36,12 +49,13 @@ export let run = function (configArg) { compileTs(config.ts,config.tsOptions) .then(() => { - compileTs(config.testTs); + plugins.beautylog.ok("compiled main TypeScript!"); + plugins.beautylog.log("now compiling tests!"); + return compileTs(config.testTs); }) .then(function () { - plugins.beautylog.ok("compiled TypeScript!"); + plugins.beautylog.ok("compiled all TypeScript!"); done.resolve(config); - }); return done.promise; };