integrate tsn and clean up

This commit is contained in:
Philipp Kunz 2016-07-01 02:28:34 +02:00
parent 88cd04d0e2
commit 1723193d27
85 changed files with 610 additions and 280 deletions

View File

@ -1,49 +0,0 @@
// import gulp
var plugins = {
beautylog: require("beautylog"),
gulp: require("gulp"),
g:{
typescript: require("gulp-typescript"),
typings:require("gulp-typings")
},
mergeStream: require("merge2"),
path: require("path")
};
paths = {
packageBase: plugins.path.resolve(
plugins.path.join(__dirname,"../")
)
};
plugins.beautylog.log('now compiling NPMTS');
plugins.gulp.task("typings",function(){
var stream = plugins.gulp.src(plugins.path.join(paths.packageBase,"ts/typings.json"))
.pipe(plugins.g.typings());
return stream;
});
plugins.gulp.task("TS",["typings"], function() {
var stream = plugins.gulp.src([
plugins.path.join(paths.packageBase,'ts/**/*.ts'),
"!" + plugins.path.join(paths.packageBase,'ts/typings/**/*.d.ts')
])
.pipe(plugins.g.typescript({
target:"ES5",
module:"commonjs"
}))
.pipe(plugins.gulp.dest(plugins.path.join(paths.packageBase, 'dist/')));
return stream;
});
plugins.gulp.task("CLI",function(){
var stream = plugins.gulp.src(plugins.path.join(paths.packageBase,"assets/cli.js"))
.pipe(plugins.gulp.dest(plugins.path.join(paths.packageBase, 'dist/')))
});
plugins.gulp.task('default',['TS',"CLI"], function() {
plugins.beautylog.success('Typescript compiled');
});
plugins.gulp.start.apply(plugins.gulp, ['default']);

2
dist/cli.js vendored
View File

@ -1,2 +0,0 @@
#!/usr/bin/env node
var index = require("./index.js");

1
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
import "typings-global";

4
dist/npmts.assets.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare var run: (configArg: any) => plugins.Q.Promise<{}>;

View File

@ -8,7 +8,7 @@ exports.run = function (configArg) {
var config = configArg;
npmts_promisechain_1.npmtsOra.text("now looking at " + "required assets".yellow);
if (config.cli == true) {
plugins.smartfile.fsaction.copy(plugins.path.join(paths.npmtsAssetsDir, "cli.js"), paths.distDir);
plugins.smartfile.fs.copy(plugins.path.join(paths.npmtsAssetsDir, "cli.js"), paths.distDir);
plugins.beautylog.ok("installed CLI assets!");
done.resolve(config);
}

4
dist/npmts.clean.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

2
dist/npmts.clean.js vendored
View File

@ -5,7 +5,7 @@ var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
var removeDist = function () {
npmts_promisechain_1.npmtsOra.text("cleaning " + "dist".yellow + " folder");
return plugins.smartfile.fsaction.remove(paths.distDir);
return plugins.smartfile.fs.remove(paths.distDir);
};
var removeTypings = function () {
var done = plugins.Q.defer();

1
dist/npmts.cli.d.ts vendored Normal file
View File

@ -0,0 +1 @@
import "typings-global";

4
dist/npmts.compile.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

1
dist/npmts.compile.helpers.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare let checkOutputPath: (tsArrayArg: any, keyArg: any) => boolean;

48
dist/npmts.compile.js vendored
View File

@ -4,38 +4,9 @@ var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var helpers = require("./npmts.compile.helpers");
var npmts_promisechain_1 = require("./npmts.promisechain");
/**
* handles definition to make them fit for modular use
*/
var definitionHandler = function (configArg) {
npmts_promisechain_1.npmtsOra.text("now making declaration files ready");
var done = plugins.Q.defer();
var configTsLenght = Object.keys(configArg.ts).length;
if (configTsLenght == 0) {
plugins.beautylog.warn("No TS file and thus no definitions found!");
done.resolve(configArg); //if there are no definition files, resolve...
}
var localCounter = 0;
for (var key in configArg.ts) {
var distPath = configArg.ts[key];
var stream = plugins.gulp.src(plugins.path.join(distPath, "**/*.d.ts"))
.pipe(plugins.g.replace(plugins.smartstring.typescript.regexReferencePath, ""))
.pipe(plugins.gulp.dest(distPath))
.pipe(plugins.g.gFunction(function () {
localCounter++;
if (localCounter == configTsLenght) {
plugins.beautylog.ok("made declaration files ready!");
done.resolve(configArg);
}
;
}, "atEnd"));
}
return done.promise;
};
var compileTs = function (tsFileArrayArg, tsOptionsArg) {
if (tsOptionsArg === void 0) { tsOptionsArg = {}; }
var done = plugins.Q.defer();
var moduleStream = plugins.merge2({ end: false });
var tsOptionsDefault = {
declaration: true,
target: "ES5",
@ -49,20 +20,9 @@ var compileTs = function (tsFileArrayArg, tsOptionsArg) {
};
for (var keyArg in tsFileArrayArg) {
if (helpers.checkOutputPath(tsFileArrayArg, keyArg)) {
var tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"])
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
.pipe(plugins.g.typescript(tsOptions(keyArg)));
var jsStream = tsStream.js
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
.pipe(plugins.gulp.dest(tsFileArrayArg[keyArg]));
var declarationStream = tsStream.dts
.pipe(plugins.gulp.dest(tsFileArrayArg[keyArg]));
moduleStream.add(tsStream, jsStream, declarationStream);
var tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"]);
}
}
moduleStream.on("queueDrain", function () {
done.resolve();
});
return done.promise;
};
exports.run = function (configArg) {
@ -75,11 +35,7 @@ exports.run = function (configArg) {
})
.then(function () {
plugins.beautylog.ok("compiled TypeScript!");
definitionHandler(config)
.then(function () {
done.resolve(config);
});
done.resolve(config);
});
/*==================== END TS Compilation =====================*/
return done.promise;
};

4
dist/npmts.configfile.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare var run: (argvArg: any) => plugins.Q.Promise<{}>;

View File

@ -9,9 +9,9 @@ exports.run = function (argvArg) {
if (argvArg.notest) {
config.notest = true;
}
if (plugins.smartfile.checks.fileExistsSync(configPath)) {
if (plugins.smartfile.fs.fileExistsSync(configPath)) {
plugins.beautylog.info("npmts.json".blue + " config file found!");
config = plugins.lodashObject.assign(config, plugins.smartfile.local.toObjectSync(configPath));
config = plugins.lodashObject.assign(config, plugins.smartfile.fs.toObjectSync(configPath));
switch (config.mode) {
case "default":
case "custom":

21
dist/npmts.install.js vendored
View File

@ -1,21 +0,0 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
exports.run = function (configArg) {
var config = configArg;
var done = plugins.Q.defer();
/* -------------------------------------------------
* ----------- install typings ---------------
* ----------------------------------------------- */
npmts_promisechain_1.npmtsOra.text("now installing " + "typings".yellow);
var absoluteTypingsArray = plugins.smartpath.transform.toAbsolute(config.typings, paths.cwd);
plugins.gulp.src(absoluteTypingsArray)
.pipe(plugins.g.typings())
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("typings installed!");
done.resolve(config);
}, "atEnd"));
return done.promise;
};

4
dist/npmts.jsdoc.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

5
dist/npmts.options.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let isCi: () => any;
export declare var run: (configArg: any) => plugins.Q.Promise<{}>;

12
dist/npmts.paths.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
import "typings-global";
export declare let npmtsPackageRoot: string;
export declare let cwd: string;
export declare let tsDir: string;
export declare let distDir: string;
export declare let docsDir: string;
export declare let testDir: string;
export declare let typingsDir: string;
export declare let coverageDir: string;
export declare let npmtsAssetsDir: string;
export declare let indexTS: string;
export declare let testTS: string;

27
dist/npmts.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,27 @@
import "typings-global";
export import beautylog = require("beautylog");
export declare let gulp: any;
export declare let g: {
gFunction: any;
istanbul: any;
jsdoc3: any;
mocha: any;
replace: any;
sourcemaps: any;
typescript: any;
typings: any;
};
export declare let lodashObject: any;
export declare let merge2: any;
export import projectinfo = require("projectinfo");
export import path = require("path");
export import Q = require("q");
export import shelljs = require("shelljs");
export declare let smartci: any;
export import smartcli = require("smartcli");
export declare let smartcov: any;
export import smartenv = require("smartenv");
export import smartfile = require("smartfile");
export import smartpath = require("smartpath");
export import smartstring = require("smartstring");
export declare let sourceMapSupport: any;

View File

@ -1,7 +1,6 @@
"use strict";
require("typings-global");
exports.beautylog = require("beautylog");
exports.fs = require("fs-extra");
exports.gulp = require("gulp");
exports.g = {
gFunction: require("gulp-function"),

6
dist/npmts.promisechain.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
import { Ora } from "beautylog";
export declare let npmtsOra: Ora;
export declare let promisechain: (argvArg: any) => plugins.Q.Promise<{}>;

View File

@ -6,7 +6,6 @@ var NpmtsAssets = require("./npmts.assets");
var NpmtsClean = require("./npmts.clean");
var NpmtsCompile = require("./npmts.compile");
var NpmtsConfigFile = require("./npmts.configfile");
var NpmtsInstall = require("./npmts.install");
var NpmtsJsdoc = require("./npmts.jsdoc");
var NpmtsOptions = require("./npmts.options");
var NpmtsTests = require("./npmts.tests");
@ -16,7 +15,6 @@ exports.promisechain = function (argvArg) {
NpmtsConfigFile.run(argvArg)
.then(NpmtsOptions.run)
.then(NpmtsClean.run)
.then(NpmtsInstall.run)
.then(NpmtsCompile.run)
.then(NpmtsAssets.run)
.then(NpmtsJsdoc.run)

View File

@ -1,9 +0,0 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
done.resolve();
return done.promise;
};

4
dist/npmts.tests.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

View File

@ -0,0 +1 @@
declare var hello: string;

1
dist/test/assets/customdir/custom.js vendored Normal file
View File

@ -0,0 +1 @@
var hello = "hello";

View File

@ -0,0 +1 @@
declare var something: string;

1
dist/test/assets/customdir/tsfile1.js vendored Normal file
View File

@ -0,0 +1 @@
var something = "something";

1
dist/test/assets/test/test.d.ts vendored Normal file
View File

@ -0,0 +1 @@
declare var testplugin: any;

8
dist/test/assets/test/test.js vendored Normal file
View File

@ -0,0 +1,8 @@
var testplugin = require("../dist/index.js");
describe("testplugins", function () {
describe(".logSomething", function () {
it("should log something", function () {
testplugin.logSomething();
});
});
});

View File

@ -1,3 +1,4 @@
declare let testplugin: {
logSomething: () => void;
};
export = testplugin;

7
dist/test/assets/ts/index.js vendored Normal file
View File

@ -0,0 +1,7 @@
"use strict";
var testplugin = {
logSomething: function () {
console.log("only function executed");
}
};
module.exports = testplugin;

1
dist/ts/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
import "typings-global";

28
dist/ts/index.js vendored Normal file
View File

@ -0,0 +1,28 @@
"use strict";
require("typings-global");
/* ================================================== *
Starting NPMTS main process.
* ================================================== */
var early = require("early");
early.start("NPMTS");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
early.stop()
.then(function () {
var npmtsProjectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.npmtsPackageRoot);
var npmtsCli = new plugins.smartcli.Smartcli();
npmtsCli.standardTask()
.then(function (argvArg) {
plugins.beautylog.figletSync("NPMTS");
plugins.beautylog.info("npmts version: " + npmtsProjectInfo.version);
try {
npmts_promisechain_1.promisechain(argvArg);
}
catch (err) {
console.log(err);
}
});
npmtsCli.addVersion(npmtsProjectInfo.version);
npmtsCli.startParse();
});

4
dist/ts/npmts.assets.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare var run: (configArg: any) => plugins.Q.Promise<{}>;

19
dist/ts/npmts.assets.js vendored Normal file
View File

@ -0,0 +1,19 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
npmts_promisechain_1.npmtsOra.text("now looking at " + "required assets".yellow);
if (config.cli == true) {
plugins.smartfile.fsaction.copy(plugins.path.join(paths.npmtsAssetsDir, "cli.js"), paths.distDir);
plugins.beautylog.ok("installed CLI assets!");
done.resolve(config);
}
else {
done.resolve(config);
}
return done.promise;
};

4
dist/ts/npmts.clean.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

30
dist/ts/npmts.clean.js vendored Normal file
View File

@ -0,0 +1,30 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
var removeDist = function () {
npmts_promisechain_1.npmtsOra.text("cleaning " + "dist".yellow + " folder");
return plugins.smartfile.fsaction.remove(paths.distDir);
};
var removeTypings = function () {
var done = plugins.Q.defer();
npmts_promisechain_1.npmtsOra.text("cleaning " + "typings".yellow + " folder");
if (false) {
}
else {
done.resolve();
}
return done.promise;
};
exports.run = function (configArg) {
npmts_promisechain_1.npmtsOra.text("cleaning up from previous builds...");
var done = plugins.Q.defer();
removeDist()
.then(removeTypings)
.then(function () {
plugins.beautylog.ok("Cleaned up from previous builds!");
done.resolve(configArg);
});
return done.promise;
};

1
dist/ts/npmts.cli.d.ts vendored Normal file
View File

@ -0,0 +1 @@
import "typings-global";

2
dist/ts/npmts.cli.js vendored Normal file
View File

@ -0,0 +1,2 @@
"use strict";
require("typings-global");

4
dist/ts/npmts.compile.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

1
dist/ts/npmts.compile.helpers.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare let checkOutputPath: (tsArrayArg: any, keyArg: any) => boolean;

16
dist/ts/npmts.compile.helpers.js vendored Normal file
View File

@ -0,0 +1,16 @@
"use strict";
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var outputPathIsDir = function (tsArrayArg, keyArg) {
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, tsArrayArg[keyArg]));
};
exports.checkOutputPath = function (tsArrayArg, keyArg) {
if (!outputPathIsDir(tsArrayArg, keyArg)) {
plugins.beautylog.warn("Skipping " + keyArg + " because " + tsArrayArg[keyArg] + " it is no directory!");
return false;
}
else {
return true;
}
;
};

41
dist/ts/npmts.compile.js vendored Normal file
View File

@ -0,0 +1,41 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var helpers = require("./npmts.compile.helpers");
var npmts_promisechain_1 = require("./npmts.promisechain");
var compileTs = function (tsFileArrayArg, tsOptionsArg) {
if (tsOptionsArg === void 0) { tsOptionsArg = {}; }
var done = plugins.Q.defer();
var tsOptionsDefault = {
declaration: true,
target: "ES5",
module: "commonjs"
};
/**
* merges default ts options with those found in npmts.json
*/
var tsOptions = function (keyArg) {
return plugins.lodashObject.assign(tsOptionsDefault, tsOptionsArg);
};
for (var keyArg in tsFileArrayArg) {
if (helpers.checkOutputPath(tsFileArrayArg, keyArg)) {
var tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"]);
}
}
return done.promise;
};
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
npmts_promisechain_1.npmtsOra.text("now compiling " + "TypeScript".yellow);
compileTs(config.ts, config.tsOptions)
.then(function () {
compileTs(config.testTs);
})
.then(function () {
plugins.beautylog.ok("compiled TypeScript!");
done.resolve(config);
});
return done.promise;
};

4
dist/ts/npmts.configfile.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare var run: (argvArg: any) => plugins.Q.Promise<{}>;

34
dist/ts/npmts.configfile.js vendored Normal file
View File

@ -0,0 +1,34 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
exports.run = function (argvArg) {
var done = plugins.Q.defer();
var config = {};
var configPath = plugins.path.join(paths.cwd, "npmts.json");
if (argvArg.notest) {
config.notest = true;
}
if (plugins.smartfile.checks.fileExistsSync(configPath)) {
plugins.beautylog.info("npmts.json".blue + " config file found!");
config = plugins.lodashObject.assign(config, plugins.smartfile.local.toObjectSync(configPath));
switch (config.mode) {
case "default":
case "custom":
plugins.beautylog.ok("mode is " + config.mode.yellow);
done.resolve(config);
break;
default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
}
;
}
else {
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
config.mode = "default";
done.resolve(config);
}
;
return done.promise;
};

4
dist/ts/npmts.jsdoc.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

28
dist/ts/npmts.jsdoc.js vendored Normal file
View File

@ -0,0 +1,28 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
var genJsdoc = function (configArg) {
var done = plugins.Q.defer();
npmts_promisechain_1.npmtsOra.text("now generating " + "JsDoc documentation".yellow);
plugins.gulp.src([
plugins.path.join(paths.cwd, "README.md"),
plugins.path.join(paths.distDir, "**/*.js")
])
.pipe(plugins.g.jsdoc3({
opts: {
destination: paths.docsDir
}
}, function () {
plugins.beautylog.ok("JsDoc documentation has been generated!");
done.resolve(configArg);
}));
return done.promise;
};
exports.run = function (configArg) {
var done = plugins.Q.defer();
genJsdoc(configArg)
.then(done.resolve);
return done.promise;
};

5
dist/ts/npmts.options.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let isCi: () => any;
export declare var run: (configArg: any) => plugins.Q.Promise<{}>;

36
dist/ts/npmts.options.js vendored Normal file
View File

@ -0,0 +1,36 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
var npmts_promisechain_1 = require("./npmts.promisechain");
exports.isCi = function () {
return plugins.smartci.check.isCi();
};
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
npmts_promisechain_1.npmtsOra.text("now determining build options...");
//handle default mode
if (config.mode == "default") {
config.typings = [
"./ts/typings.json"
];
config.ts = (_a = {},
_a["./ts/**/*.ts"] = "./dist/",
_a
);
config.testTs = (_b = {},
_b["./test/test.ts"] = "./test/",
_b
);
config.test = ["./index.js"];
}
//check if config.tsOptions is available
config.tsOptions ? void (0) : config.tsOptions = {};
config.coverageTreshold ? void (0) : config.coverageTreshold = 70;
// handle docs
config.docs ? void (0) : config.docs = {};
plugins.beautylog.ok("build options are ready!");
done.resolve(config);
return done.promise;
var _a, _b;
};

12
dist/ts/npmts.paths.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
import "typings-global";
export declare let npmtsPackageRoot: string;
export declare let cwd: string;
export declare let tsDir: string;
export declare let distDir: string;
export declare let docsDir: string;
export declare let testDir: string;
export declare let typingsDir: string;
export declare let coverageDir: string;
export declare let npmtsAssetsDir: string;
export declare let indexTS: string;
export declare let testTS: string;

18
dist/ts/npmts.paths.js vendored Normal file
View File

@ -0,0 +1,18 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
//Npmts Paths
exports.npmtsPackageRoot = plugins.path.join(__dirname, "../");
//Project paths
exports.cwd = process.cwd();
//Directories
exports.tsDir = plugins.path.join(exports.cwd, "ts/");
exports.distDir = plugins.path.join(exports.cwd, "dist/");
exports.docsDir = plugins.path.join(exports.cwd, "docs/");
exports.testDir = plugins.path.join(exports.cwd, "test/");
exports.typingsDir = plugins.path.join(exports.cwd, "ts/typings/");
exports.coverageDir = plugins.path.join(exports.cwd, "coverage/");
exports.npmtsAssetsDir = plugins.path.join(__dirname, "../assets/");
//Files
exports.indexTS = plugins.path.join(exports.cwd, "ts/index.ts");
exports.testTS = plugins.path.join(exports.cwd, "ts/test.ts");

28
dist/ts/npmts.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
import "typings-global";
export import beautylog = require("beautylog");
export import fs = require("fs-extra");
export declare let gulp: any;
export declare let g: {
gFunction: any;
istanbul: any;
jsdoc3: any;
mocha: any;
replace: any;
sourcemaps: any;
typescript: any;
typings: any;
};
export declare let lodashObject: any;
export declare let merge2: any;
export import projectinfo = require("projectinfo");
export import path = require("path");
export import Q = require("q");
export import shelljs = require("shelljs");
export import smartci = require("smartci");
export import smartcli = require("smartcli");
export import smartcov = require("smartcov");
export import smartenv = require("smartenv");
export import smartfile = require("smartfile");
export import smartpath = require("smartpath");
export import smartstring = require("smartstring");
export declare let sourceMapSupport: any;

29
dist/ts/npmts.plugins.js vendored Normal file
View File

@ -0,0 +1,29 @@
"use strict";
require("typings-global");
exports.beautylog = require("beautylog");
exports.fs = require("fs-extra");
exports.gulp = require("gulp");
exports.g = {
gFunction: require("gulp-function"),
istanbul: require("gulp-istanbul"),
jsdoc3: require("gulp-jsdoc3"),
mocha: require("gulp-mocha"),
replace: require("gulp-replace"),
sourcemaps: require("gulp-sourcemaps"),
typescript: require("gulp-typescript"),
typings: require("gulp-typings")
};
exports.lodashObject = require('lodash/fp/object');
exports.merge2 = require("merge2");
exports.projectinfo = require("projectinfo");
exports.path = require("path");
exports.Q = require("q");
exports.shelljs = require("shelljs");
exports.smartci = require("smartci");
exports.smartcli = require("smartcli");
exports.smartcov = require("smartcov");
exports.smartenv = require("smartenv");
exports.smartfile = require("smartfile");
exports.smartpath = require("smartpath");
exports.smartstring = require("smartstring");
exports.sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing

47
dist/ts/npmts.promisechain.js vendored Normal file
View File

@ -0,0 +1,47 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
exports.npmtsOra = new plugins.beautylog.Ora("setting up TaskChain", "cyan");
var NpmtsAssets = require("./npmts.assets");
var NpmtsClean = require("./npmts.clean");
var NpmtsCompile = require("./npmts.compile");
var NpmtsConfigFile = require("./npmts.configfile");
var NpmtsJsdoc = require("./npmts.jsdoc");
var NpmtsOptions = require("./npmts.options");
var NpmtsTests = require("./npmts.tests");
exports.promisechain = function (argvArg) {
var done = plugins.Q.defer();
exports.npmtsOra.start();
NpmtsConfigFile.run(argvArg)
.then(NpmtsOptions.run)
.then(NpmtsClean.run)
.then(NpmtsCompile.run)
.then(NpmtsAssets.run)
.then(NpmtsJsdoc.run)
.then(NpmtsTests.run)
.then(function (configArg) {
var shipString = "" +
"\n" +
"\n" +
" # # ( )\n" +
" ___#_#___|__\n" +
" _ |____________| _\n" +
" _=====| | | | | |==== _\n" +
" =====| |.---------------------------. | |====\n" +
" <--------------------' . . . . . . . . '--------------/\n" +
" \\ /\n" +
" \\___________________________________________________________/\n" +
" wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n" +
" wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n" +
" wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n";
if (process.env.CI) {
console.log(shipString);
plugins.beautylog.success("READY TO SHIP!");
}
else {
plugins.beautylog.success("Done!");
}
done.resolve();
});
return done.promise;
};

4
dist/ts/npmts.tests.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

76
dist/ts/npmts.tests.js vendored Normal file
View File

@ -0,0 +1,76 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
/**
*
* @returns {*}
*/
var istanbul = function (configArg) {
npmts_promisechain_1.npmtsOra.text("Instrumentalizing transpiled JS...");
var done = plugins.Q.defer();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
.pipe(plugins.g.istanbul()) // Covering files
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!");
done.resolve(configArg);
}, "atEnd"));
return done.promise;
};
/**
*
* @returns {*}
*/
var mocha = function (configArg) {
var done = plugins.Q.defer();
npmts_promisechain_1.npmtsOra.end(); // end npmtsOra for tests.
var stream = plugins.gulp.src(["./test/test.js"])
.pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("Tests have passed!");
done.resolve(configArg);
}, "atEnd"));
return done.promise;
};
var coverage = function (configArg) {
var done = plugins.Q.defer();
plugins.smartcov.get.percentage(plugins.path.join(paths.coverageDir, "lcov.info"))
.then(function (percentageArg) {
if (percentageArg >= configArg.coverageTreshold) {
plugins.beautylog.ok("your coverage of " + percentageArg.toString().blue + "% ".blue + "exceeds your treshold of " +
configArg.coverageTreshold.toString().blue + "%".blue);
}
else {
plugins.beautylog.warn("your coverage of " + percentageArg + "% " + "fails your treshold of " +
configArg.coverageTreshold + "%");
plugins.beautylog.error("exiting due to coverage failure");
process.exit(1);
}
done.resolve(configArg);
});
return done.promise;
};
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
if (config.notest != true) {
npmts_promisechain_1.npmtsOra.text("now starting tests");
plugins.beautylog.log("-------------------------------------------------------\n" +
"*************************** TESTS: ***************************\n" +
"--------------------------------------------------------------");
istanbul(config)
.then(mocha)
.then(coverage)
.then(function () {
done.resolve(config);
});
}
else {
npmts_promisechain_1.npmtsOra.end();
done.resolve(config);
}
return done.promise;
};

View File

@ -11,7 +11,7 @@
"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": "(cd compile && node compile.js)"
"compile": "(tsc)"
},
"repository": {
"type": "git",
@ -28,10 +28,11 @@
},
"homepage": "https://gitlab.com/pushrocks/npmts#readme",
"dependencies": {
"@types/minimatch": "^2.0.22-alpha",
"@types/q": "0.0.21-alpha",
"beautylog": "5.0.11",
"@types/shelljs": "^0.3.21-alpha",
"beautylog": "5.0.12",
"early": "^2.0.13",
"fs-extra": "^0.30.0",
"gulp": "3.9.1",
"gulp-concat": "^2.6.0",
"gulp-function": "^1.3.6",
@ -46,13 +47,15 @@
"q": "^1.4.1",
"shelljs": "^0.7.0",
"smartci": "0.0.1",
"smartcli": "1.0.2",
"smartcli": "1.0.4",
"smartcov": "0.0.6",
"smartenv": "1.2.5",
"smartfile": "3.0.10",
"smartfile": "4.0.9",
"smartpath": "3.2.2",
"smartstring": "^2.0.6",
"source-map-support": "^0.4.0",
"smartstring": "^2.0.10",
"source-map-support": "^0.4.1",
"tsn": "^1.0.1",
"typescript": "^2.0.0-dev.20160630",
"typings-global": "*"
},
"devDependencies": {}

View File

@ -1,3 +0,0 @@
var hello = "hello";
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImN1c3RvbS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxJQUFJLEtBQUssR0FBRyxPQUFPLENBQUMiLCJmaWxlIjoiY3VzdG9tLmpzIiwic291cmNlc0NvbnRlbnQiOlsidmFyIGhlbGxvID0gXCJoZWxsb1wiOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==

View File

@ -1,2 +0,0 @@
var hello = "hello";
//# sourceMappingURL=custom.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"custom.js","sourceRoot":"","sources":["custom.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,OAAO,CAAC"}

View File

@ -1 +0,0 @@
var hello = "hello";

View File

@ -1,2 +0,0 @@
var something = "something";
//# sourceMappingURL=tsfile1.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"tsfile1.js","sourceRoot":"","sources":["tsfile1.ts"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,WAAW,CAAC"}

View File

@ -1 +0,0 @@
var something = "something";

View File

@ -1,7 +0,0 @@
{
"ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
}
}

View File

@ -1,9 +0,0 @@
/// <reference path="./typings/index.d.ts" />
var testplugin = {
logSomething: function () {
console.log("only function executed");
}
};
module.exports = testplugin;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDZDQUE2QztBQUM3QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9pbmRleC5kLnRzXCIgLz5cbmxldCB0ZXN0cGx1Z2luID0ge1xuICAgIGxvZ1NvbWV0aGluZzogZnVuY3Rpb24oKXtcbiAgICAgICAgY29uc29sZS5sb2coXCJvbmx5IGZ1bmN0aW9uIGV4ZWN1dGVkXCIpO1xuICAgIH1cbn07XG5tb2R1bGUuZXhwb3J0cyA9IHRlc3RwbHVnaW47Il19

View File

@ -1,19 +0,0 @@
{
"mode":"default",
"ts":{
"./customdir/*.ts":"./"
},
"tsOptions":{
"target":"ES5"
},
"typings":[
"./ts/typings.json",
"./subts1/typings.json",
"./subts2/typings.json",
"./customdir/typings.json"
],
"docs": {
"publish":true
},
"cli":true
}

View File

@ -1,16 +0,0 @@
{
"name": "testpackage",
"version": "2.0.0",
"description": "",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/pushrocks/npmts.git"
},
"scripts": {
"test": "(npmts)"
},
"author": "",
"license": "ISC",
"dependencies": {}
}

View File

@ -1,7 +0,0 @@
{
"ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
}
}

Binary file not shown.

View File

@ -1,2 +0,0 @@
/// <reference path="../ts/typings/index.d.ts" />
declare var testplugin: any;

View File

@ -1,11 +0,0 @@
/// <reference path="../ts/typings/index.d.ts" />
var testplugin = require("../dist/index.js");
describe("testplugins", function () {
describe(".logSomething", function () {
it("should log something", function () {
testplugin.logSomething();
});
});
});
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsaURBQWlEO0FBQ2pELElBQUksVUFBVSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzdDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixFQUFFLENBQUMsc0JBQXNCLEVBQUM7WUFDdEIsVUFBVSxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQzdCLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvaW5kZXguZC50c1wiIC8+XG52YXIgdGVzdHBsdWdpbiA9IHJlcXVpcmUoXCIuLi9kaXN0L2luZGV4LmpzXCIpO1xuZGVzY3JpYmUoXCJ0ZXN0cGx1Z2luc1wiLGZ1bmN0aW9uKCl7XG4gICAgZGVzY3JpYmUoXCIubG9nU29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgaXQoXCJzaG91bGQgbG9nIHNvbWV0aGluZ1wiLGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICB0ZXN0cGx1Z2luLmxvZ1NvbWV0aGluZygpXG4gICAgICAgIH0pO1xuICAgIH0pO1xufSk7Il19

View File

@ -1,9 +0,0 @@
/// <reference path="../ts/typings/index.d.ts" />
var testplugin = require("../dist/index.js");
describe("testplugins",function(){
describe(".logSomething",function(){
it("should log something",function(){
testplugin.logSomething()
});
});
});

View File

@ -1,8 +0,0 @@
{
"ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
}
}

View File

@ -1,7 +0,0 @@
/// <reference path="./typings/index.d.ts" />
let testplugin = {
logSomething: function(){
console.log("only function executed");
}
};
module.exports = testplugin;

View File

@ -1,8 +0,0 @@
{
"globalDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts"
}
}

View File

@ -1,3 +0,0 @@
var something = "something";
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRzZmlsZTEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsSUFBSSxTQUFTLEdBQUcsV0FBVyxDQUFDIiwiZmlsZSI6InRzZmlsZTEuanMiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgc29tZXRoaW5nID0gXCJzb21ldGhpbmdcIjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

View File

@ -8,7 +8,7 @@ export var run = function(configArg){
let config = configArg;
npmtsOra.text("now looking at " + "required assets".yellow);
if(config.cli == true){
plugins.smartfile.fsaction.copy(plugins.path.join(paths.npmtsAssetsDir,"cli.js"),paths.distDir);
plugins.smartfile.fs.copy(plugins.path.join(paths.npmtsAssetsDir,"cli.js"),paths.distDir);
plugins.beautylog.ok("installed CLI assets!");
done.resolve(config);
} else {

View File

@ -5,7 +5,7 @@ import {npmtsOra} from "./npmts.promisechain";
let removeDist = function(){
npmtsOra.text("cleaning " + "dist".yellow + " folder");
return plugins.smartfile.fsaction.remove(paths.distDir);
return plugins.smartfile.fs.remove(paths.distDir);
};
let removeTypings = function(){

View File

@ -21,7 +21,8 @@ let compileTs = (tsFileArrayArg,tsOptionsArg = {}) => {
};
for (let keyArg in tsFileArrayArg) {
if (helpers.checkOutputPath(tsFileArrayArg,keyArg)) {
let tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"]);
let filesToConvert = plugins.smartfile.fs.listFileTree(plugins.path.resolve(keyArg),"**/*.ts");
plugins.tsn.compile(filesToConvert,tsFileArrayArg[keyArg]);
}
}
return done.promise;

View File

@ -8,11 +8,11 @@ export var run = function(argvArg){
if(argvArg.notest){
config.notest = true;
}
if(plugins.smartfile.checks.fileExistsSync(configPath)){
if(plugins.smartfile.fs.fileExistsSync(configPath)){
plugins.beautylog.info("npmts.json".blue + " config file found!");
config = plugins.lodashObject.assign(
config,
plugins.smartfile.local.toObjectSync(configPath)
plugins.smartfile.fs.toObjectSync(configPath)
);
switch (config.mode){
case "default":

View File

@ -1,17 +1,12 @@
import "typings-global";
export import beautylog = require("beautylog");
export import fs = require("fs-extra");
export let gulp = require("gulp");
export let g = {
gFunction: require("gulp-function"),
istanbul: require("gulp-istanbul"),
jsdoc3: require("gulp-jsdoc3"),
mocha: require("gulp-mocha"),
replace: require("gulp-replace"),
sourcemaps: require("gulp-sourcemaps"),
typescript: require("gulp-typescript"),
typings: require("gulp-typings")
replace: require("gulp-replace")
};
export let lodashObject = require('lodash/fp/object');
export let merge2 = require("merge2");
@ -19,11 +14,12 @@ export import projectinfo = require("projectinfo");
export import path = require("path");
export import Q = require("q");
export import shelljs = require("shelljs");
export import smartci = require("smartci");
export let smartci = require("smartci");
export import smartcli = require("smartcli");
export import smartcov = require("smartcov");
export let smartcov = require("smartcov");
export import smartenv = require("smartenv");
export import smartfile = require("smartfile");
export import smartpath = require("smartpath");
export import smartstring = require("smartstring");
export let sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing
export let sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing
export import tsn = require("tsn");

View File

@ -1,5 +1,6 @@
import "typings-global";
import plugins = require("./npmts.plugins");
import {Ora} from "beautylog"
export let npmtsOra = new plugins.beautylog.Ora("setting up TaskChain","cyan");

View File

@ -1,8 +0,0 @@
{
"globalDependencies": {
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
"istanbul": "registry:dt/istanbul#0.4.0+20160316155526",
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
}
}

8
tsconfig.json Normal file
View File

@ -0,0 +1,8 @@
{
"compilerOptions": {
"declaration": true,
"module": "commonjs",
"target": "ES5",
"outDir": "./dist/"
}
}