now using commonjs module system
This commit is contained in:
parent
2035045aef
commit
d5407e33dd
1
assets/node-shebang.js
Normal file
1
assets/node-shebang.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
#!/usr/bin/env node
|
@ -6,26 +6,30 @@ var plugins = {
|
|||||||
typescript: require("gulp-typescript"),
|
typescript: require("gulp-typescript"),
|
||||||
header: require("gulp-header")
|
header: require("gulp-header")
|
||||||
},
|
},
|
||||||
mergeStream: require("merge2")
|
mergeStream: require("merge2"),
|
||||||
|
path: require("path")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
paths = {
|
||||||
|
packageBase: plugins.path.resolve(
|
||||||
|
plugins.path.join(__dirname,"../")
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
plugins.beautylog.log('now compiling NPMTS');
|
plugins.beautylog.log('now compiling NPMTS');
|
||||||
|
|
||||||
plugins.gulp.task('indexTS', function() {
|
plugins.gulp.task('indexTS', function() {
|
||||||
var tsResult = plugins.gulp.src('../ts/index.ts')
|
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({
|
.pipe(plugins.g.typescript({
|
||||||
out:"index.js",
|
target:"ES5",
|
||||||
declaration:true
|
module:"commonjs"
|
||||||
}));
|
}))
|
||||||
|
.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
|
||||||
return plugins.mergeStream([
|
.pipe(plugins.gulp.dest(plugins.path.join(paths.packageBase, 'dist/')));
|
||||||
tsResult.dts.pipe(plugins.gulp.dest('../')),
|
return stream;
|
||||||
tsResult.js
|
|
||||||
.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
|
|
||||||
.pipe(plugins.gulp.dest('../'))
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
plugins.gulp.task('default',['indexTS'], function() {
|
plugins.gulp.task('default',['indexTS'], function() {
|
||||||
|
3
dist/cli.js
vendored
Normal file
3
dist/cli.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
8
dist/index.js
vendored
Normal file
8
dist/index.js
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
console.log("**** starting NPMTS ****");
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var promisechain = require("./npmts.promisechain");
|
||||||
|
plugins.beautylog.figletSync("NPMTS");
|
||||||
|
promisechain.run();
|
3
dist/npmts.cli.js
vendored
Normal file
3
dist/npmts.cli.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
91
dist/npmts.compile.js
vendored
Normal file
91
dist/npmts.compile.js
vendored
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
plugins.beautylog.log("now running custom tasks");
|
||||||
|
var moduleStream = plugins.mergeStream({ end: false });
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- first install typings ---------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
var typingsDone = plugins.q.defer();
|
||||||
|
var typingsCounter = 0;
|
||||||
|
var typingsCounterAdvance = function () {
|
||||||
|
typingsCounter++;
|
||||||
|
if (typeof config.typings[typingsCounter] != "undefined") {
|
||||||
|
installTypings();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugins.beautylog.success("custom typings installed successfully");
|
||||||
|
typingsDone.resolve();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var installTypings = function () {
|
||||||
|
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
|
||||||
|
plugins.typings.install({ production: false, cwd: plugins.path.join(paths.cwd, config.typings[typingsCounter]) })
|
||||||
|
.then(function () {
|
||||||
|
typingsCounterAdvance();
|
||||||
|
}, function () {
|
||||||
|
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
|
||||||
|
typingsCounterAdvance();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
installTypings();
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- second compile TS -------------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
typingsDone.promise.then(function () {
|
||||||
|
for (var key in config.ts) {
|
||||||
|
plugins.beautylog.log("now compiling" + key.blue);
|
||||||
|
var outputPathIsDir;
|
||||||
|
try {
|
||||||
|
if (plugins.fs.statSync(plugins.path.join(paths.cwd, config.ts[key])).isDirectory()) {
|
||||||
|
outputPathIsDir = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
outputPathIsDir = false;
|
||||||
|
}
|
||||||
|
//do some evaluation of the environment
|
||||||
|
var outputNameSpecified = (!outputPathIsDir
|
||||||
|
&& (plugins.path.extname(config.ts[key]) == ".js"));
|
||||||
|
var outputName = (function () {
|
||||||
|
if (outputNameSpecified) {
|
||||||
|
return plugins.path.basename(config.ts[key]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
var outputDir = (function () {
|
||||||
|
if (outputNameSpecified) {
|
||||||
|
return plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return plugins.path.join(paths.cwd, config.ts[key]);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, key), "!**/typings/**"])
|
||||||
|
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out: outputName,
|
||||||
|
target: "ES5",
|
||||||
|
module: "commonjs"
|
||||||
|
}))
|
||||||
|
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||||
|
.pipe(plugins.gulp.dest(outputDir));
|
||||||
|
moduleStream.add(stream);
|
||||||
|
}
|
||||||
|
moduleStream.on("queueDrain", function () {
|
||||||
|
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||||
|
moduleStream.on("finish", function () {
|
||||||
|
done.resolve(config);
|
||||||
|
});
|
||||||
|
moduleStream.end();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
31
dist/npmts.configfile.js
vendored
Normal file
31
dist/npmts.configfile.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
exports.run = function () {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
var config = {};
|
||||||
|
var configPath = plugins.path.join(paths.cwd, "npmts.json");
|
||||||
|
if (plugins.smartfile.checks.fileExistsSync(configPath)) {
|
||||||
|
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
||||||
|
config = plugins.smartfile.readFileToObject(configPath);
|
||||||
|
switch (config.mode) {
|
||||||
|
case "default":
|
||||||
|
case "custom":
|
||||||
|
plugins.beautylog.log("mode is " + config.mode.yellow);
|
||||||
|
done.resolve(config);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
||||||
|
config.mode = "default";
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
return done.promise;
|
||||||
|
};
|
28
dist/npmts.options.js
vendored
Normal file
28
dist/npmts.options.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
if (typeof config.coveralls === "undefined") {
|
||||||
|
config.coveralls = false;
|
||||||
|
}
|
||||||
|
if (config.mode == "default") {
|
||||||
|
config.typings = [
|
||||||
|
"./ts/"
|
||||||
|
];
|
||||||
|
config.ts = (_a = {},
|
||||||
|
_a["./ts/**/*.ts"] = "./dist/",
|
||||||
|
_a["./test/test.ts"] = "./test/",
|
||||||
|
_a
|
||||||
|
);
|
||||||
|
config.test = ["./index.js"];
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
var _a;
|
||||||
|
};
|
11
dist/npmts.paths.js
vendored
Normal file
11
dist/npmts.paths.js
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = {};
|
||||||
|
paths.cwd = plugins.smartcli.get.cwd().path;
|
||||||
|
paths.tsDir = plugins.path.join(paths.cwd, "ts/");
|
||||||
|
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
||||||
|
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
|
||||||
|
paths.testDir = plugins.path.join(paths.cwd, "test/");
|
||||||
|
module.exports = paths;
|
23
dist/npmts.plugins.js
vendored
Normal file
23
dist/npmts.plugins.js
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = {
|
||||||
|
beautylog: require("beautylog"),
|
||||||
|
fs: require("fs-extra"),
|
||||||
|
gulp: require("gulp"),
|
||||||
|
g: {
|
||||||
|
coveralls: require("gulp-coveralls"),
|
||||||
|
istanbul: require("gulp-istanbul"),
|
||||||
|
mocha: require("gulp-mocha"),
|
||||||
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
|
typescript: require("gulp-typescript")
|
||||||
|
},
|
||||||
|
mergeStream: require("merge2"),
|
||||||
|
sourceMapSupport: require("source-map-support").install(),
|
||||||
|
path: require("path"),
|
||||||
|
q: require("q"),
|
||||||
|
smartcli: require("smartcli"),
|
||||||
|
smartfile: require("smartfile"),
|
||||||
|
typings: require("typings")
|
||||||
|
};
|
||||||
|
module.exports = plugins;
|
15
dist/npmts.promisechain.js
vendored
Normal file
15
dist/npmts.promisechain.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var NpmtsConfigFile = require("./npmts.configfile");
|
||||||
|
var NpmtsOptions = require("./npmts.options");
|
||||||
|
var NpmtsCompile = require("./npmts.compile");
|
||||||
|
var NpmtsTests = require("./npmts.tests");
|
||||||
|
exports.run = function () {
|
||||||
|
var promisechain;
|
||||||
|
NpmtsConfigFile.run()
|
||||||
|
.then(NpmtsOptions.run)
|
||||||
|
.then(NpmtsCompile.run)
|
||||||
|
.then(NpmtsTests.run);
|
||||||
|
return promisechain;
|
||||||
|
};
|
40
dist/npmts.tests.js
vendored
Normal file
40
dist/npmts.tests.js
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
var istanbul = function () {
|
||||||
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
|
||||||
|
.pipe(plugins.g.istanbul())
|
||||||
|
.pipe(plugins.g.istanbul.hookRequire());
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
var mocha = function () {
|
||||||
|
var stream = plugins.gulp.src(["./test/test.js"])
|
||||||
|
.pipe(plugins.g.mocha())
|
||||||
|
.pipe(plugins.g.istanbul.writeReports())
|
||||||
|
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
var coveralls = function () {
|
||||||
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
|
||||||
|
.pipe(plugins.g.coveralls());
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
istanbul().on("finish", function () {
|
||||||
|
mocha().on("finish", function () {
|
||||||
|
if (process.env.TRAVIS && config.coveralls) {
|
||||||
|
coveralls().on("finish", function () {
|
||||||
|
done.resolve(config);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
61
index.d.ts
vendored
61
index.d.ts
vendored
@ -1,61 +0,0 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
|
||||||
declare module NpmtsPlugins {
|
|
||||||
var init: () => {
|
|
||||||
beautylog: any;
|
|
||||||
fs: any;
|
|
||||||
gulp: any;
|
|
||||||
g: {
|
|
||||||
coveralls: any;
|
|
||||||
istanbul: any;
|
|
||||||
mocha: any;
|
|
||||||
sourcemaps: any;
|
|
||||||
typescript: any;
|
|
||||||
};
|
|
||||||
mergeStream: any;
|
|
||||||
sourceMapSupport: any;
|
|
||||||
path: any;
|
|
||||||
q: any;
|
|
||||||
smartcli: any;
|
|
||||||
smartfile: any;
|
|
||||||
typings: any;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
declare module NpmtsPaths {
|
|
||||||
var init: () => any;
|
|
||||||
}
|
|
||||||
declare module NpmtsConfigFile {
|
|
||||||
var run: () => any;
|
|
||||||
}
|
|
||||||
declare module NpmtsOptions {
|
|
||||||
var run: (configArg: any) => any;
|
|
||||||
}
|
|
||||||
declare module NpmtsCompile {
|
|
||||||
var run: (configArg: any) => any;
|
|
||||||
}
|
|
||||||
declare module NpmtsTests {
|
|
||||||
var run: (configArg: any) => any;
|
|
||||||
}
|
|
||||||
declare module NpmtsPromisechain {
|
|
||||||
var init: () => any;
|
|
||||||
}
|
|
||||||
declare var plugins: {
|
|
||||||
beautylog: any;
|
|
||||||
fs: any;
|
|
||||||
gulp: any;
|
|
||||||
g: {
|
|
||||||
coveralls: any;
|
|
||||||
istanbul: any;
|
|
||||||
mocha: any;
|
|
||||||
sourcemaps: any;
|
|
||||||
typescript: any;
|
|
||||||
};
|
|
||||||
mergeStream: any;
|
|
||||||
sourceMapSupport: any;
|
|
||||||
path: any;
|
|
||||||
q: any;
|
|
||||||
smartcli: any;
|
|
||||||
smartfile: any;
|
|
||||||
typings: any;
|
|
||||||
};
|
|
||||||
declare var paths: any;
|
|
||||||
declare var promisechain: any;
|
|
255
index.js
255
index.js
@ -1,255 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsPlugins;
|
|
||||||
(function (NpmtsPlugins) {
|
|
||||||
NpmtsPlugins.init = function () {
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
fs: require("fs-extra"),
|
|
||||||
gulp: require("gulp"),
|
|
||||||
g: {
|
|
||||||
coveralls: require("gulp-coveralls"),
|
|
||||||
istanbul: require("gulp-istanbul"),
|
|
||||||
mocha: require("gulp-mocha"),
|
|
||||||
sourcemaps: require("gulp-sourcemaps"),
|
|
||||||
typescript: require("gulp-typescript")
|
|
||||||
},
|
|
||||||
mergeStream: require("merge2"),
|
|
||||||
sourceMapSupport: require("source-map-support").install(),
|
|
||||||
path: require("path"),
|
|
||||||
q: require("q"),
|
|
||||||
smartcli: require("smartcli"),
|
|
||||||
smartfile: require("smartfile"),
|
|
||||||
typings: require("typings")
|
|
||||||
};
|
|
||||||
return plugins;
|
|
||||||
};
|
|
||||||
})(NpmtsPlugins || (NpmtsPlugins = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsPaths;
|
|
||||||
(function (NpmtsPaths) {
|
|
||||||
NpmtsPaths.init = function () {
|
|
||||||
var paths = {};
|
|
||||||
paths.cwd = plugins.smartcli.get.cwd().path;
|
|
||||||
paths.tsDir = plugins.path.join(paths.cwd, "ts/");
|
|
||||||
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
|
||||||
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
|
|
||||||
paths.testDir = plugins.path.join(paths.cwd, "test/");
|
|
||||||
return paths;
|
|
||||||
};
|
|
||||||
})(NpmtsPaths || (NpmtsPaths = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsConfigFile;
|
|
||||||
(function (NpmtsConfigFile) {
|
|
||||||
NpmtsConfigFile.run = function () {
|
|
||||||
var done = plugins.q.defer();
|
|
||||||
var config = {};
|
|
||||||
var configPath = plugins.path.join(paths.cwd, "npmts.json");
|
|
||||||
if (plugins.smartfile.checks.fileExistsSync(configPath)) {
|
|
||||||
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
|
||||||
config = plugins.smartfile.readFileToObject(configPath);
|
|
||||||
switch (config.mode) {
|
|
||||||
case "default":
|
|
||||||
case "custom":
|
|
||||||
plugins.beautylog.log("mode is " + config.mode.yellow);
|
|
||||||
done.resolve(config);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
|
||||||
config.mode = "default";
|
|
||||||
done.resolve(config);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
})(NpmtsConfigFile || (NpmtsConfigFile = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsOptions;
|
|
||||||
(function (NpmtsOptions) {
|
|
||||||
NpmtsOptions.run = function (configArg) {
|
|
||||||
var done = plugins.q.defer();
|
|
||||||
var config = configArg;
|
|
||||||
if (typeof config.coveralls === "undefined") {
|
|
||||||
config.coveralls = false;
|
|
||||||
}
|
|
||||||
if (config.mode == "default") {
|
|
||||||
config.typings = [
|
|
||||||
"./ts/"
|
|
||||||
];
|
|
||||||
config.ts = (_a = {},
|
|
||||||
_a["./ts/**/*.ts"] = "./dist/",
|
|
||||||
_a["./test/test.ts"] = "./test/",
|
|
||||||
_a
|
|
||||||
);
|
|
||||||
config.test = ["./index.js"];
|
|
||||||
done.resolve(config);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
done.resolve(config);
|
|
||||||
}
|
|
||||||
return done.promise;
|
|
||||||
var _a;
|
|
||||||
};
|
|
||||||
})(NpmtsOptions || (NpmtsOptions = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsCompile;
|
|
||||||
(function (NpmtsCompile) {
|
|
||||||
NpmtsCompile.run = function (configArg) {
|
|
||||||
var done = plugins.q.defer();
|
|
||||||
var config = configArg;
|
|
||||||
plugins.beautylog.log("now running custom tasks");
|
|
||||||
var moduleStream = plugins.mergeStream({ end: false });
|
|
||||||
/* -------------------------------------------------
|
|
||||||
* ----------- first install typings ---------------
|
|
||||||
* ----------------------------------------------- */
|
|
||||||
var typingsDone = plugins.q.defer();
|
|
||||||
var typingsCounter = 0;
|
|
||||||
var typingsCounterAdvance = function () {
|
|
||||||
typingsCounter++;
|
|
||||||
if (typeof config.typings[typingsCounter] != "undefined") {
|
|
||||||
installTypings();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugins.beautylog.success("custom typings installed successfully");
|
|
||||||
typingsDone.resolve();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var installTypings = function () {
|
|
||||||
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
|
|
||||||
plugins.typings.install({ production: false, cwd: plugins.path.join(paths.cwd, config.typings[typingsCounter]) })
|
|
||||||
.then(function () {
|
|
||||||
typingsCounterAdvance();
|
|
||||||
}, function () {
|
|
||||||
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
|
|
||||||
typingsCounterAdvance();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
installTypings();
|
|
||||||
/* -------------------------------------------------
|
|
||||||
* ----------- second compile TS -------------------
|
|
||||||
* ----------------------------------------------- */
|
|
||||||
typingsDone.promise.then(function () {
|
|
||||||
for (var key in config.ts) {
|
|
||||||
plugins.beautylog.log("now compiling" + key.blue);
|
|
||||||
var outputPathIsDir;
|
|
||||||
try {
|
|
||||||
if (plugins.fs.statSync(plugins.path.join(paths.cwd, config.ts[key])).isDirectory()) {
|
|
||||||
outputPathIsDir = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
outputPathIsDir = false;
|
|
||||||
}
|
|
||||||
//do some evaluation of the environment
|
|
||||||
var outputNameSpecified = (!outputPathIsDir
|
|
||||||
&& (plugins.path.extname(config.ts[key]) == ".js"));
|
|
||||||
var outputName = (function () {
|
|
||||||
if (outputNameSpecified) {
|
|
||||||
return plugins.path.basename(config.ts[key]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
var outputDir = (function () {
|
|
||||||
if (outputNameSpecified) {
|
|
||||||
return plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return plugins.path.join(paths.cwd, config.ts[key]);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, key), "!**/typings/**"])
|
|
||||||
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
|
||||||
.pipe(plugins.g.typescript({
|
|
||||||
out: outputName,
|
|
||||||
target: "ES5",
|
|
||||||
module: "commonjs"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
|
||||||
.pipe(plugins.gulp.dest(outputDir));
|
|
||||||
moduleStream.add(stream);
|
|
||||||
}
|
|
||||||
moduleStream.on("queueDrain", function () {
|
|
||||||
plugins.beautylog.success("custom TypeScript installed successfully");
|
|
||||||
moduleStream.on("finish", function () {
|
|
||||||
done.resolve(config);
|
|
||||||
});
|
|
||||||
moduleStream.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
})(NpmtsCompile || (NpmtsCompile = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsTests;
|
|
||||||
(function (NpmtsTests) {
|
|
||||||
NpmtsTests.run = function (configArg) {
|
|
||||||
var done = plugins.q.defer();
|
|
||||||
var config = configArg;
|
|
||||||
var istanbul = function () {
|
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
|
|
||||||
.pipe(plugins.g.istanbul())
|
|
||||||
.pipe(plugins.g.istanbul.hookRequire());
|
|
||||||
return stream;
|
|
||||||
};
|
|
||||||
var mocha = function () {
|
|
||||||
var stream = plugins.gulp.src(["./test/test.js"])
|
|
||||||
.pipe(plugins.g.mocha())
|
|
||||||
.pipe(plugins.g.istanbul.writeReports())
|
|
||||||
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
|
||||||
return stream;
|
|
||||||
};
|
|
||||||
var coveralls = function () {
|
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
|
|
||||||
.pipe(plugins.g.coveralls());
|
|
||||||
return stream;
|
|
||||||
};
|
|
||||||
istanbul().on("finish", function () {
|
|
||||||
mocha().on("finish", function () {
|
|
||||||
if (process.env.TRAVIS && config.coveralls) {
|
|
||||||
coveralls().on("finish", function () {
|
|
||||||
done.resolve(config);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
done.resolve(config);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
})(NpmtsTests || (NpmtsTests = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsPromisechain;
|
|
||||||
(function (NpmtsPromisechain) {
|
|
||||||
NpmtsPromisechain.init = function () {
|
|
||||||
var promisechain;
|
|
||||||
NpmtsConfigFile.run()
|
|
||||||
.then(NpmtsOptions.run)
|
|
||||||
.then(NpmtsCompile.run)
|
|
||||||
.then(NpmtsTests.run);
|
|
||||||
return promisechain;
|
|
||||||
};
|
|
||||||
})(NpmtsPromisechain || (NpmtsPromisechain = {}));
|
|
||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
/// <reference path="./npmts.plugins.ts" />
|
|
||||||
/// <reference path="./npmts.cli.ts" />
|
|
||||||
/// <reference path="./npmts.paths.ts" />
|
|
||||||
/// <reference path="./npmts.configfile.ts" />
|
|
||||||
/// <reference path="./npmts.options.ts" />
|
|
||||||
/// <reference path="./npmts.compile.ts" />
|
|
||||||
/// <reference path="./npmts.tests.ts" />
|
|
||||||
/// <reference path="./npmts.promisechain.ts" />
|
|
||||||
console.log("**** starting NPMTS ****");
|
|
||||||
var plugins = NpmtsPlugins.init();
|
|
||||||
plugins.beautylog.figletSync("NPMTS");
|
|
||||||
var paths = NpmtsPaths.init();
|
|
||||||
var promisechain = NpmtsPromisechain.init();
|
|
@ -2,13 +2,12 @@
|
|||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"description": "write npm modules with TypeScript",
|
"description": "write npm modules with TypeScript",
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "./index.d.ts",
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"npmts": "./index.js"
|
"npmts": "dist/cli.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(cd compile && node compile.js) && (cd test/assets && node ../../index.js)",
|
"test": "(cd compile && node compile.js) && (cd test/assets && node ../../dist/index.js)",
|
||||||
"release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)"
|
"release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -29,7 +28,9 @@
|
|||||||
"beautylog": "2.1.1",
|
"beautylog": "2.1.1",
|
||||||
"fs-extra": "^0.26.5",
|
"fs-extra": "^0.26.5",
|
||||||
"gulp": "3.9.1",
|
"gulp": "3.9.1",
|
||||||
|
"gulp-concat": "^2.6.0",
|
||||||
"gulp-coveralls": "^0.1.4",
|
"gulp-coveralls": "^0.1.4",
|
||||||
|
"gulp-if": "^2.0.0",
|
||||||
"gulp-istanbul": "^0.10.3",
|
"gulp-istanbul": "^0.10.3",
|
||||||
"gulp-mocha": "^2.2.0",
|
"gulp-mocha": "^2.2.0",
|
||||||
"gulp-sourcemaps": "^1.6.0",
|
"gulp-sourcemaps": "^1.6.0",
|
||||||
|
14
ts/index.ts
14
ts/index.ts
@ -1,14 +1,6 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
/// <reference path="./npmts.plugins.ts" />
|
|
||||||
/// <reference path="./npmts.cli.ts" />
|
|
||||||
/// <reference path="./npmts.paths.ts" />
|
|
||||||
/// <reference path="./npmts.configfile.ts" />
|
|
||||||
/// <reference path="./npmts.options.ts" />
|
|
||||||
/// <reference path="./npmts.compile.ts" />
|
|
||||||
/// <reference path="./npmts.tests.ts" />
|
|
||||||
/// <reference path="./npmts.promisechain.ts" />
|
|
||||||
console.log("**** starting NPMTS ****");
|
console.log("**** starting NPMTS ****");
|
||||||
var plugins = NpmtsPlugins.init();
|
import plugins = require("./npmts.plugins");
|
||||||
|
import promisechain = require("./npmts.promisechain");
|
||||||
plugins.beautylog.figletSync("NPMTS");
|
plugins.beautylog.figletSync("NPMTS");
|
||||||
var paths = NpmtsPaths.init();
|
promisechain.run();
|
||||||
var promisechain = NpmtsPromisechain.init();
|
|
||||||
|
@ -1 +1 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
@ -1,92 +1,92 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
module NpmtsCompile {
|
import plugins = require("./npmts.plugins");
|
||||||
export var run = function(configArg){
|
import paths = require("./npmts.paths");
|
||||||
var done = plugins.q.defer();
|
export var run = function(configArg){
|
||||||
var config = configArg;
|
var done = plugins.q.defer();
|
||||||
plugins.beautylog.log("now running custom tasks");
|
var config = configArg;
|
||||||
var moduleStream = plugins.mergeStream({end: false});
|
plugins.beautylog.log("now running custom tasks");
|
||||||
/* -------------------------------------------------
|
var moduleStream = plugins.mergeStream({end: false});
|
||||||
* ----------- first install typings ---------------
|
/* -------------------------------------------------
|
||||||
* ----------------------------------------------- */
|
* ----------- first install typings ---------------
|
||||||
var typingsDone = plugins.q.defer();
|
* ----------------------------------------------- */
|
||||||
var typingsCounter:number = 0;
|
var typingsDone = plugins.q.defer();
|
||||||
var typingsCounterAdvance = function(){
|
var typingsCounter:number = 0;
|
||||||
typingsCounter++;
|
var typingsCounterAdvance = function(){
|
||||||
if(typeof config.typings[typingsCounter] != "undefined"){
|
typingsCounter++;
|
||||||
installTypings();
|
if(typeof config.typings[typingsCounter] != "undefined"){
|
||||||
} else {
|
installTypings();
|
||||||
plugins.beautylog.success("custom typings installed successfully");
|
} else {
|
||||||
typingsDone.resolve();
|
plugins.beautylog.success("custom typings installed successfully");
|
||||||
}
|
typingsDone.resolve();
|
||||||
};
|
}
|
||||||
var installTypings = function() {
|
};
|
||||||
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
|
var installTypings = function() {
|
||||||
plugins.typings.install({production: false, cwd: plugins.path.join(paths.cwd,config.typings[typingsCounter])})
|
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
|
||||||
.then(function(){
|
plugins.typings.install({production: false, cwd: plugins.path.join(paths.cwd,config.typings[typingsCounter])})
|
||||||
typingsCounterAdvance();
|
.then(function(){
|
||||||
},function(){
|
typingsCounterAdvance();
|
||||||
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
|
},function(){
|
||||||
typingsCounterAdvance();
|
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
|
||||||
});
|
typingsCounterAdvance();
|
||||||
};
|
|
||||||
installTypings();
|
|
||||||
/* -------------------------------------------------
|
|
||||||
* ----------- second compile TS -------------------
|
|
||||||
* ----------------------------------------------- */
|
|
||||||
typingsDone.promise.then(function(){
|
|
||||||
for (var key in config.ts) {
|
|
||||||
plugins.beautylog.log("now compiling" + key.blue);
|
|
||||||
var outputPathIsDir:boolean;
|
|
||||||
try {
|
|
||||||
if(plugins.fs.statSync(plugins.path.join(paths.cwd,config.ts[key])).isDirectory()){
|
|
||||||
outputPathIsDir = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(err) {
|
|
||||||
outputPathIsDir = false;
|
|
||||||
}
|
|
||||||
//do some evaluation of the environment
|
|
||||||
var outputNameSpecified:boolean = (
|
|
||||||
!outputPathIsDir
|
|
||||||
&& (plugins.path.extname(config.ts[key]) == ".js")
|
|
||||||
);
|
|
||||||
var outputName = (function(){
|
|
||||||
if(outputNameSpecified){
|
|
||||||
return plugins.path.basename(config.ts[key])
|
|
||||||
} else {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
var outputDir = (function(){
|
|
||||||
if(outputNameSpecified){
|
|
||||||
return plugins.path.dirname(
|
|
||||||
plugins.path.join(paths.cwd,config.ts[key])
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return plugins.path.join(paths.cwd,config.ts[key])
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,key),"!**/typings/**"])
|
|
||||||
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
|
||||||
.pipe(plugins.g.typescript({
|
|
||||||
out: outputName,
|
|
||||||
target: "ES5",
|
|
||||||
module: "commonjs"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
|
||||||
//.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
|
|
||||||
.pipe(plugins.gulp.dest(outputDir));
|
|
||||||
moduleStream.add(stream);
|
|
||||||
}
|
|
||||||
moduleStream.on("queueDrain",function(){
|
|
||||||
plugins.beautylog.success("custom TypeScript installed successfully");
|
|
||||||
moduleStream.on("finish",function(){
|
|
||||||
done.resolve(config);
|
|
||||||
});
|
|
||||||
moduleStream.end();
|
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
installTypings();
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- second compile TS -------------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
typingsDone.promise.then(function(){
|
||||||
|
for (var key in config.ts) {
|
||||||
|
plugins.beautylog.log("now compiling" + key.blue);
|
||||||
|
var outputPathIsDir:boolean;
|
||||||
|
try {
|
||||||
|
if(plugins.fs.statSync(plugins.path.join(paths.cwd,config.ts[key])).isDirectory()){
|
||||||
|
outputPathIsDir = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
outputPathIsDir = false;
|
||||||
|
}
|
||||||
|
//do some evaluation of the environment
|
||||||
|
var outputNameSpecified:boolean = (
|
||||||
|
!outputPathIsDir
|
||||||
|
&& (plugins.path.extname(config.ts[key]) == ".js")
|
||||||
|
);
|
||||||
|
var outputName = (function(){
|
||||||
|
if(outputNameSpecified){
|
||||||
|
return plugins.path.basename(config.ts[key])
|
||||||
|
} else {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
var outputDir = (function(){
|
||||||
|
if(outputNameSpecified){
|
||||||
|
return plugins.path.dirname(
|
||||||
|
plugins.path.join(paths.cwd,config.ts[key])
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return plugins.path.join(paths.cwd,config.ts[key])
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,key),"!**/typings/**"])
|
||||||
|
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out: outputName,
|
||||||
|
target: "ES5",
|
||||||
|
module: "commonjs"
|
||||||
|
}))
|
||||||
|
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||||
|
//.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
|
||||||
|
.pipe(plugins.gulp.dest(outputDir));
|
||||||
|
moduleStream.add(stream);
|
||||||
|
}
|
||||||
|
moduleStream.on("queueDrain",function(){
|
||||||
|
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||||
|
moduleStream.on("finish",function(){
|
||||||
|
done.resolve(config);
|
||||||
|
});
|
||||||
|
moduleStream.end();
|
||||||
});
|
});
|
||||||
return done.promise;
|
});
|
||||||
}
|
return done.promise;
|
||||||
}
|
};
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
module NpmtsConfigFile {
|
import plugins = require("./npmts.plugins");
|
||||||
export var run = function(){
|
import paths = require("./npmts.paths");
|
||||||
var done = plugins.q.defer();
|
export var run = function(){
|
||||||
var config:any = {};
|
var done = plugins.q.defer();
|
||||||
var configPath = plugins.path.join(paths.cwd,"npmts.json");
|
var config:any = {};
|
||||||
if(plugins.smartfile.checks.fileExistsSync(configPath)){
|
var configPath = plugins.path.join(paths.cwd,"npmts.json");
|
||||||
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
if(plugins.smartfile.checks.fileExistsSync(configPath)){
|
||||||
config = plugins.smartfile.readFileToObject(configPath);
|
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
||||||
switch (config.mode){
|
config = plugins.smartfile.readFileToObject(configPath);
|
||||||
case "default":
|
switch (config.mode){
|
||||||
case "custom":
|
case "default":
|
||||||
plugins.beautylog.log("mode is " + config.mode.yellow);
|
case "custom":
|
||||||
done.resolve(config);
|
plugins.beautylog.log("mode is " + config.mode.yellow);
|
||||||
break;
|
done.resolve(config);
|
||||||
default:
|
break;
|
||||||
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
default:
|
||||||
};
|
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
||||||
} else {
|
|
||||||
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
|
||||||
config.mode = "default";
|
|
||||||
done.resolve(config);
|
|
||||||
};
|
};
|
||||||
return done.promise;
|
} else {
|
||||||
}
|
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
||||||
}
|
config.mode = "default";
|
||||||
|
done.resolve(config);
|
||||||
|
};
|
||||||
|
return done.promise;
|
||||||
|
};
|
@ -1,24 +1,23 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
module NpmtsOptions {
|
import plugins = require("./npmts.plugins");
|
||||||
export var run = function(configArg){
|
export var run = function(configArg){
|
||||||
var done = plugins.q.defer();
|
var done = plugins.q.defer();
|
||||||
var config = configArg;
|
var config = configArg;
|
||||||
if (typeof config.coveralls === "undefined"){
|
if (typeof config.coveralls === "undefined"){
|
||||||
config.coveralls = false;
|
config.coveralls = false;
|
||||||
}
|
|
||||||
if (config.mode == "default"){
|
|
||||||
config.typings = [
|
|
||||||
"./ts/"
|
|
||||||
];
|
|
||||||
config.ts = {
|
|
||||||
["./ts/**/*.ts"]: "./dist/",
|
|
||||||
["./test/test.ts"]: "./test/"
|
|
||||||
};
|
|
||||||
config.test = ["./index.js"];
|
|
||||||
done.resolve(config);
|
|
||||||
} else {
|
|
||||||
done.resolve(config);
|
|
||||||
}
|
|
||||||
return done.promise;
|
|
||||||
}
|
}
|
||||||
}
|
if (config.mode == "default"){
|
||||||
|
config.typings = [
|
||||||
|
"./ts/"
|
||||||
|
];
|
||||||
|
config.ts = {
|
||||||
|
["./ts/**/*.ts"]: "./dist/",
|
||||||
|
["./test/test.ts"]: "./test/"
|
||||||
|
};
|
||||||
|
config.test = ["./index.js"];
|
||||||
|
done.resolve(config);
|
||||||
|
} else {
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
};
|
@ -1,12 +1,9 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
module NpmtsPaths {
|
import plugins = require("./npmts.plugins");
|
||||||
export var init = function() {
|
var paths:any = {};
|
||||||
var paths:any = {};
|
paths.cwd = plugins.smartcli.get.cwd().path;
|
||||||
paths.cwd = plugins.smartcli.get.cwd().path;
|
paths.tsDir = plugins.path.join(paths.cwd,"ts/");
|
||||||
paths.tsDir = plugins.path.join(paths.cwd,"ts/");
|
paths.indexTS = plugins.path.join(paths.cwd,"ts/index.ts");
|
||||||
paths.indexTS = plugins.path.join(paths.cwd,"ts/index.ts");
|
paths.testTS = plugins.path.join(paths.cwd,"ts/test.ts");
|
||||||
paths.testTS = plugins.path.join(paths.cwd,"ts/test.ts");
|
paths.testDir = plugins.path.join(paths.cwd,"test/");
|
||||||
paths.testDir = plugins.path.join(paths.cwd,"test/");
|
export = paths;
|
||||||
return paths;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +1,22 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
module NpmtsPlugins {
|
var plugins = {
|
||||||
export var init = function() {
|
beautylog: require("beautylog"),
|
||||||
var plugins = {
|
fs: require("fs-extra"),
|
||||||
beautylog: require("beautylog"),
|
gulp: require("gulp"),
|
||||||
fs: require("fs-extra"),
|
g: {
|
||||||
gulp: require("gulp"),
|
coveralls: require("gulp-coveralls"),
|
||||||
g: {
|
istanbul: require("gulp-istanbul"),
|
||||||
coveralls: require("gulp-coveralls"),
|
mocha: require("gulp-mocha"),
|
||||||
istanbul: require("gulp-istanbul"),
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
mocha: require("gulp-mocha"),
|
typescript: require("gulp-typescript")
|
||||||
sourcemaps: require("gulp-sourcemaps"),
|
|
||||||
typescript: require("gulp-typescript")
|
|
||||||
|
|
||||||
},
|
},
|
||||||
mergeStream: require("merge2"),
|
mergeStream: require("merge2"),
|
||||||
sourceMapSupport:require("source-map-support").install(),
|
sourceMapSupport:require("source-map-support").install(),
|
||||||
path: require("path"),
|
path: require("path"),
|
||||||
q:require("q"),
|
q:require("q"),
|
||||||
smartcli: require("smartcli"),
|
smartcli: require("smartcli"),
|
||||||
smartfile: require("smartfile"),
|
smartfile: require("smartfile"),
|
||||||
typings: require("typings")
|
typings: require("typings")
|
||||||
};
|
};
|
||||||
return plugins;
|
export = plugins;
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,13 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
module NpmtsPromisechain {
|
import NpmtsConfigFile = require("./npmts.configfile");
|
||||||
export var init = function(){
|
import NpmtsOptions = require("./npmts.options");
|
||||||
var promisechain;
|
import NpmtsCompile = require("./npmts.compile");
|
||||||
NpmtsConfigFile.run()
|
import NpmtsTests = require("./npmts.tests");
|
||||||
.then(NpmtsOptions.run)
|
export var run = function(){
|
||||||
.then(NpmtsCompile.run)
|
var promisechain;
|
||||||
.then(NpmtsTests.run);
|
NpmtsConfigFile.run()
|
||||||
return promisechain;
|
.then(NpmtsOptions.run)
|
||||||
}
|
.then(NpmtsCompile.run)
|
||||||
}
|
.then(NpmtsTests.run);
|
||||||
|
return promisechain;
|
||||||
|
};
|
@ -1,44 +1,44 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
module NpmtsTests {
|
import plugins = require("./npmts.plugins");
|
||||||
export var run = function(configArg) {
|
import paths = require("./npmts.paths");
|
||||||
var done = plugins.q.defer();
|
export var run = function(configArg) {
|
||||||
var config = configArg;
|
var done = plugins.q.defer();
|
||||||
var istanbul = function () {
|
var config = configArg;
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
|
var istanbul = function () {
|
||||||
// Covering files
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
|
||||||
.pipe(plugins.g.istanbul())
|
// Covering files
|
||||||
// Force `require` to return covered files
|
.pipe(plugins.g.istanbul())
|
||||||
.pipe(plugins.g.istanbul.hookRequire());
|
// Force `require` to return covered files
|
||||||
return stream;
|
.pipe(plugins.g.istanbul.hookRequire());
|
||||||
};
|
return stream;
|
||||||
|
};
|
||||||
|
|
||||||
var mocha = function () {
|
var mocha = function () {
|
||||||
var stream = plugins.gulp.src(["./test/test.js"])
|
var stream = plugins.gulp.src(["./test/test.js"])
|
||||||
.pipe(plugins.g.mocha())
|
.pipe(plugins.g.mocha())
|
||||||
// Creating the reports after tests ran
|
// Creating the reports after tests ran
|
||||||
.pipe(plugins.g.istanbul.writeReports())
|
.pipe(plugins.g.istanbul.writeReports())
|
||||||
// Enforce a coverage of at least 90%
|
// Enforce a coverage of at least 90%
|
||||||
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
||||||
return stream;
|
return stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
var coveralls = function(){
|
var coveralls = function(){
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
|
||||||
.pipe(plugins.g.coveralls());
|
.pipe(plugins.g.coveralls());
|
||||||
return stream;
|
return stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
istanbul().on("finish",function(){
|
istanbul().on("finish",function(){
|
||||||
mocha().on("finish",function(){
|
mocha().on("finish",function(){
|
||||||
if(process.env.TRAVIS && config.coveralls){
|
if(process.env.TRAVIS && config.coveralls){
|
||||||
coveralls().on("finish",function(){
|
coveralls().on("finish",function(){
|
||||||
done.resolve(config);
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
}
|
})
|
||||||
})
|
} else {
|
||||||
});
|
done.resolve(config);
|
||||||
return done.promise;
|
}
|
||||||
}
|
})
|
||||||
}
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user