integrate tsn and clean up
This commit is contained in:
2
dist/cli.js
vendored
2
dist/cli.js
vendored
@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
var index = require("./index.js");
|
1
dist/index.d.ts
vendored
Normal file
1
dist/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import "typings-global";
|
4
dist/npmts.assets.d.ts
vendored
Normal file
4
dist/npmts.assets.d.ts
vendored
Normal 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<{}>;
|
2
dist/npmts.assets.js
vendored
2
dist/npmts.assets.js
vendored
@ -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
4
dist/npmts.clean.d.ts
vendored
Normal 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
2
dist/npmts.clean.js
vendored
@ -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
1
dist/npmts.cli.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import "typings-global";
|
4
dist/npmts.compile.d.ts
vendored
Normal file
4
dist/npmts.compile.d.ts
vendored
Normal 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
1
dist/npmts.compile.helpers.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare let checkOutputPath: (tsArrayArg: any, keyArg: any) => boolean;
|
48
dist/npmts.compile.js
vendored
48
dist/npmts.compile.js
vendored
@ -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
4
dist/npmts.configfile.d.ts
vendored
Normal 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<{}>;
|
4
dist/npmts.configfile.js
vendored
4
dist/npmts.configfile.js
vendored
@ -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
21
dist/npmts.install.js
vendored
@ -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
4
dist/npmts.jsdoc.d.ts
vendored
Normal 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
5
dist/npmts.options.d.ts
vendored
Normal 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
12
dist/npmts.paths.d.ts
vendored
Normal 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
27
dist/npmts.plugins.d.ts
vendored
Normal 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;
|
1
dist/npmts.plugins.js
vendored
1
dist/npmts.plugins.js
vendored
@ -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
6
dist/npmts.promisechain.d.ts
vendored
Normal 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<{}>;
|
2
dist/npmts.promisechain.js
vendored
2
dist/npmts.promisechain.js
vendored
@ -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)
|
||||
|
9
dist/npmts.publish.js
vendored
9
dist/npmts.publish.js
vendored
@ -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
4
dist/npmts.tests.d.ts
vendored
Normal 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/test/assets/customdir/custom.d.ts
vendored
Normal file
1
dist/test/assets/customdir/custom.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare var hello: string;
|
1
dist/test/assets/customdir/custom.js
vendored
Normal file
1
dist/test/assets/customdir/custom.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
var hello = "hello";
|
1
dist/test/assets/customdir/tsfile1.d.ts
vendored
Normal file
1
dist/test/assets/customdir/tsfile1.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare var something: string;
|
1
dist/test/assets/customdir/tsfile1.js
vendored
Normal file
1
dist/test/assets/customdir/tsfile1.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
var something = "something";
|
1
dist/test/assets/test/test.d.ts
vendored
Normal file
1
dist/test/assets/test/test.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare var testplugin: any;
|
8
dist/test/assets/test/test.js
vendored
Normal file
8
dist/test/assets/test/test.js
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var testplugin = require("../dist/index.js");
|
||||
describe("testplugins", function () {
|
||||
describe(".logSomething", function () {
|
||||
it("should log something", function () {
|
||||
testplugin.logSomething();
|
||||
});
|
||||
});
|
||||
});
|
4
dist/test/assets/ts/index.d.ts
vendored
Normal file
4
dist/test/assets/ts/index.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
declare let testplugin: {
|
||||
logSomething: () => void;
|
||||
};
|
||||
export = testplugin;
|
7
dist/test/assets/ts/index.js
vendored
Normal file
7
dist/test/assets/ts/index.js
vendored
Normal 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
1
dist/ts/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import "typings-global";
|
28
dist/ts/index.js
vendored
Normal file
28
dist/ts/index.js
vendored
Normal 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
4
dist/ts/npmts.assets.d.ts
vendored
Normal 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
19
dist/ts/npmts.assets.js
vendored
Normal 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
4
dist/ts/npmts.clean.d.ts
vendored
Normal 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
30
dist/ts/npmts.clean.js
vendored
Normal 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
1
dist/ts/npmts.cli.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import "typings-global";
|
2
dist/ts/npmts.cli.js
vendored
Normal file
2
dist/ts/npmts.cli.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
4
dist/ts/npmts.compile.d.ts
vendored
Normal file
4
dist/ts/npmts.compile.d.ts
vendored
Normal 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
1
dist/ts/npmts.compile.helpers.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare let checkOutputPath: (tsArrayArg: any, keyArg: any) => boolean;
|
16
dist/ts/npmts.compile.helpers.js
vendored
Normal file
16
dist/ts/npmts.compile.helpers.js
vendored
Normal 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
41
dist/ts/npmts.compile.js
vendored
Normal 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
4
dist/ts/npmts.configfile.d.ts
vendored
Normal 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
34
dist/ts/npmts.configfile.js
vendored
Normal 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
4
dist/ts/npmts.jsdoc.d.ts
vendored
Normal 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
28
dist/ts/npmts.jsdoc.js
vendored
Normal 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
5
dist/ts/npmts.options.d.ts
vendored
Normal 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
36
dist/ts/npmts.options.js
vendored
Normal 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
12
dist/ts/npmts.paths.d.ts
vendored
Normal 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
18
dist/ts/npmts.paths.js
vendored
Normal 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
28
dist/ts/npmts.plugins.d.ts
vendored
Normal 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
29
dist/ts/npmts.plugins.js
vendored
Normal 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
47
dist/ts/npmts.promisechain.js
vendored
Normal 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
4
dist/ts/npmts.tests.d.ts
vendored
Normal 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
76
dist/ts/npmts.tests.js
vendored
Normal 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;
|
||||
};
|
Reference in New Issue
Block a user