Compare commits

...

29 Commits

Author SHA1 Message Date
73f5a0b055 3.6.7 2016-03-26 18:06:38 +01:00
f2a169ac7d added better Test log identifier 2016-03-26 18:06:29 +01:00
3cdd22044e 3.6.6 2016-03-26 17:36:00 +01:00
60d200135e fix small promise error 2016-03-26 17:35:55 +01:00
e8238dc907 3.6.5 2016-03-26 17:26:48 +01:00
007e7539c8 removed redundant if 2016-03-26 17:25:45 +01:00
e3c2c56548 3.6.4 2016-03-26 14:08:56 +01:00
f0954b19e0 improved execution order 2016-03-26 14:08:48 +01:00
48a9d19b8e 3.6.3 2016-03-23 15:55:12 +01:00
7d39683972 fix doPublish function 2016-03-23 15:55:07 +01:00
01e9f386a6 3.6.2 2016-03-23 15:47:34 +01:00
2f4fb28b5d made options handling easier 2016-03-23 15:47:28 +01:00
50b14e60c6 3.6.1 2016-03-23 15:23:14 +01:00
4753a4ff82 fix small error 2016-03-23 15:23:04 +01:00
fe9ea47208 3.6.0 2016-03-23 14:13:09 +01:00
c8f29dc146 now correctly determining release builds 2016-03-23 14:12:58 +01:00
e7e228c900 now cleaning up 2016-03-21 01:07:34 +01:00
b76cb1376d update deps 2016-03-20 19:09:58 +01:00
eed1a65415 add some beauty 2016-03-14 04:53:35 +01:00
040100b73f 3.5.0 2016-03-14 04:33:10 +01:00
3ce49c7e97 now handling cli option 2016-03-14 04:32:52 +01:00
55d7018891 add ship 2016-03-12 11:09:54 +01:00
d98d035902 3.4.1 2016-03-12 10:26:53 +01:00
217af24d25 fixs some cosmetics 2016-03-12 10:26:42 +01:00
11c43f59d9 update devDeps 2016-03-12 10:23:32 +01:00
14c36dd894 3.4.0 2016-03-12 10:21:34 +01:00
9f74fab2b2 now using gulp-typings 2016-03-12 10:21:16 +01:00
8efa67a4ff 3.3.2 2016-02-25 08:39:48 +01:00
f7304f59a5 add optional docs publishing 2016-02-25 08:39:38 +01:00
36 changed files with 547 additions and 320 deletions

8
.gitignore vendored
View File

@ -1,10 +1,10 @@
.idea/ .idea/
.c9/ .c9/
node_modules/ node_modules/
test/**/node_modules/ test/assets/**/node_modules/
test/assets/docs/ test/assets/**/docs/
test/**/typings/ test/assets/**/typings/
test/**/coverage/ test/assets/**/coverage/
ts/*.js ts/*.js
ts/*.js.map ts/*.js.map
ts/typings/ ts/typings/

View File

@ -2,5 +2,6 @@
support support
compile compile
test/ test/
docs/
examples examples
.gitignore .gitignore

8
dist/index.js vendored
View File

@ -1,6 +1,12 @@
"use strict";
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
console.log("**** starting NPMTS ****"); console.log("**** starting NPMTS ****");
var plugins = require("./npmts.plugins"); var plugins = require("./npmts.plugins");
var promisechain = require("./npmts.promisechain"); var promisechain = require("./npmts.promisechain");
plugins.beautylog.figletSync("NPMTS"); plugins.beautylog.figletSync("NPMTS");
promisechain.run(); try {
promisechain.run();
}
catch (err) {
console.log(err);
}

18
dist/npmts.assets.js vendored Normal file
View File

@ -0,0 +1,18 @@
"use strict";
/// <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 looking at required assets");
if (config.cli == true) {
plugins.smartfile.fsaction.copy(plugins.path.join(paths.npmtsAssetsDir, "cli.js"), paths.distDir);
plugins.beautylog.ok("CLI asset has been installed!");
done.resolve(config);
}
else {
done.resolve(config);
}
return done.promise;
};

13
dist/npmts.clean.js vendored Normal file
View File

@ -0,0 +1,13 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
exports.run = function (configArg) {
plugins.beautylog.log("now cleaning up from previous builds");
var done = plugins.Q.defer();
plugins.smartfile.fsaction.remove(paths.distDir)
.then(function () {
done.resolve(configArg);
});
return done.promise;
};

121
dist/npmts.compile.js vendored
View File

@ -1,89 +1,62 @@
"use strict";
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins"); var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths"); var paths = require("./npmts.paths");
exports.run = function (configArg) { exports.run = function (configArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
var config = configArg; var config = configArg;
plugins.beautylog.log("now running custom tasks"); plugins.beautylog.log("now compiling " + "TypeScript".yellow);
var moduleStream = plugins.merge2({ end: false }); var moduleStream = plugins.merge2({ end: false });
/* ------------------------------------------------- /* -------------------------------------------------
* ----------- first install typings --------------- * ----------- compile TypeScript --------------------------
* ----------------------------------------------- */ * ----------------------------------------------- */
var typingsDone = plugins.Q.defer(); for (var key in config.ts) {
var typingsCounter = 0; var outputPathIsDir;
var typingsCounterAdvance = function () { try {
typingsCounter++; if (plugins.fs.statSync(plugins.path.join(paths.cwd, config.ts[key])).isDirectory()) {
if (typeof config.typings[typingsCounter] != "undefined") { outputPathIsDir = true;
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 () { catch (err) {
plugins.beautylog.success("custom TypeScript installed successfully"); outputPathIsDir = false;
moduleStream.on("finish", function () { }
done.resolve(config); //do some evaluation of the environment
}); var outputNameSpecified = (!outputPathIsDir
moduleStream.end(); && (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.ok("TypeScript has been compiled!");
moduleStream.on("finish", function () {
done.resolve(config);
}); });
moduleStream.end();
}); });
/*==================== END TYPESCRIPT =====================*/
return done.promise; return done.promise;
}; };

View File

@ -1,3 +1,4 @@
"use strict";
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins"); var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths"); var paths = require("./npmts.paths");
@ -7,7 +8,7 @@ exports.run = function () {
var configPath = plugins.path.join(paths.cwd, "npmts.json"); var configPath = plugins.path.join(paths.cwd, "npmts.json");
if (plugins.smartfile.checks.fileExistsSync(configPath)) { if (plugins.smartfile.checks.fileExistsSync(configPath)) {
plugins.beautylog.info("npmts.json".blue + " config file found!"); plugins.beautylog.info("npmts.json".blue + " config file found!");
config = plugins.smartfile.readFileToObject(configPath); config = plugins.smartfile.local.toObjectSync(configPath);
switch (config.mode) { switch (config.mode) {
case "default": case "default":
case "custom": case "custom":
@ -16,6 +17,7 @@ exports.run = function () {
break; break;
default: default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red); plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
} }
; ;
} }

20
dist/npmts.install.js vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
exports.run = function (configArg) {
var config = configArg;
var done = plugins.Q.defer();
/* -------------------------------------------------
* ----------- install typings ---------------
* ----------------------------------------------- */
plugins.beautylog.log("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 have been installed!");
done.resolve(config);
}, "atEnd"));
return done.promise;
};

28
dist/npmts.jsdoc.js vendored
View File

@ -1,3 +1,4 @@
"use strict";
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins"); var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths"); var paths = require("./npmts.paths");
@ -13,11 +14,12 @@ var genJsdoc = function (configArg) {
destination: paths.docsDir destination: paths.docsDir
} }
}, function () { }, function () {
plugins.beautylog.ok("JsDoc documentation has been generated!");
done.resolve(configArg); done.resolve(configArg);
})); }));
return done.promise; return done.promise;
}; };
var publishDocs = function (configArg) { exports.publishDocs = function (configArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
var gitUrl = plugins.projectinfo.npm(paths.cwd, { var gitUrl = plugins.projectinfo.npm(paths.cwd, {
gitAccessToken: process.env.GITHUB_TOKEN gitAccessToken: process.env.GITHUB_TOKEN
@ -32,28 +34,22 @@ var publishDocs = function (configArg) {
+ "&& git push --force --quiet " + "&& git push --force --quiet "
+ "\"" + gitUrl + "\" " + "\"" + gitUrl + "\" "
+ "master:gh-pages " + "> /dev/null 2>&1"; + "master:gh-pages " + "> /dev/null 2>&1";
if (plugins.smartenv.getEnv().isTravis) { plugins.beautylog.log("now publishing JsDoc documentation to GitHub");
plugins.beautylog.log("now publishing docs to GitHub"); if (!plugins.shelljs.which('git')) {
if (!plugins.shelljs.which('git')) { plugins.beautylog.error('Git is not installed!');
plugins.beautylog.error('Git is not installed'); plugins.shelljs.exit(1);
plugins.shelljs.exit(1);
}
else if (plugins.shelljs.exec(deployScript).code !== 0) {
plugins.beautylog.error('Error: Git failed');
plugins.shelljs.exit(1);
}
plugins.beautylog.success("Docs have been deployed to GitHub");
done.resolve(configArg);
} }
else { else if (plugins.shelljs.exec(deployScript).code !== 0) {
done.resolve(configArg); plugins.beautylog.error('Git failed!');
plugins.shelljs.exit(1);
} }
plugins.beautylog.ok("JsDoc documentation has been deployed to GitHub!");
done.resolve(configArg);
return done.promise; return done.promise;
}; };
exports.run = function (configArg) { exports.run = function (configArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
genJsdoc(configArg) genJsdoc(configArg)
.then(publishDocs)
.then(done.resolve); .then(done.resolve);
return done.promise; return done.promise;
}; };

33
dist/npmts.options.js vendored
View File

@ -1,14 +1,22 @@
"use strict";
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins"); var plugins = require("./npmts.plugins");
exports.isRelease = function () {
return plugins.smartci.check.isCi()
&& plugins.smartci.check.isTaggedCommit();
};
exports.doPublish = function () {
return exports.isRelease()
&& plugins.smartci.get.subJobNumber() == 1;
};
exports.run = function (configArg) { exports.run = function (configArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
var config = configArg; var config = configArg;
if (typeof config.coveralls === "undefined") { plugins.beautylog.log("now determining build options");
config.coveralls = false; //handle default mode
}
if (config.mode == "default") { if (config.mode == "default") {
config.typings = [ config.typings = [
"./ts/" "./ts/typings.json"
]; ];
config.ts = (_a = {}, config.ts = (_a = {},
_a["./ts/**/*.ts"] = "./dist/", _a["./ts/**/*.ts"] = "./dist/",
@ -16,11 +24,20 @@ exports.run = function (configArg) {
_a _a
); );
config.test = ["./index.js"]; config.test = ["./index.js"];
done.resolve(config);
}
else {
done.resolve(config);
} }
// handle state of current build
exports.isRelease() ? plugins.beautylog.info("All right: This is a RELEASE build!")
: plugins.beautylog.info("NOT A RELEASE build!");
exports.isRelease() && exports.doPublish() ? plugins.beautylog.info("All right: This is the first subBuild, so this one publishes coverage and docs when tests succeed!")
: plugins.beautylog.info("We are not publishing anything!");
// handle coveralls
config.coveralls ? void (0) : config.coveralls = false;
exports.doPublish() ? void (0) : config.coveralls = false;
// handle docs
config.docs ? void (0) : config.docs = {};
config.docs.publish ? void (0) : config.docs.publish = false;
exports.doPublish() ? void (0) : config.docs.publish = false;
done.resolve(config);
return done.promise; return done.promise;
var _a; var _a;
}; };

2
dist/npmts.paths.js vendored
View File

@ -1,3 +1,4 @@
"use strict";
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins"); var plugins = require("./npmts.plugins");
var paths = {}; var paths = {};
@ -7,6 +8,7 @@ paths.tsDir = plugins.path.join(paths.cwd, "ts/");
paths.distDir = plugins.path.join(paths.cwd, "dist/"); paths.distDir = plugins.path.join(paths.cwd, "dist/");
paths.docsDir = plugins.path.join(paths.cwd, "docs/"); paths.docsDir = plugins.path.join(paths.cwd, "docs/");
paths.testDir = plugins.path.join(paths.cwd, "test/"); paths.testDir = plugins.path.join(paths.cwd, "test/");
paths.npmtsAssetsDir = plugins.path.join(__dirname, "../assets/");
//Files //Files
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");

48
dist/npmts.plugins.js vendored
View File

@ -1,26 +1,26 @@
"use strict";
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var plugins = { exports.beautylog = require("beautylog");
beautylog: require("beautylog"), exports.fs = require("fs-extra");
fs: require("fs-extra"), exports.gulp = require("gulp");
gulp: require("gulp"), exports.g = {
g: { coveralls: require("gulp-coveralls"),
coveralls: require("gulp-coveralls"), gFunction: require("gulp-function"),
gFunction: require("gulp-function"), istanbul: require("gulp-istanbul"),
istanbul: require("gulp-istanbul"), jsdoc3: require("gulp-jsdoc3"),
jsdoc3: require("gulp-jsdoc3"), mocha: require("gulp-mocha"),
mocha: require("gulp-mocha"), sourcemaps: require("gulp-sourcemaps"),
sourcemaps: require("gulp-sourcemaps"), typescript: require("gulp-typescript"),
typescript: require("gulp-typescript") typings: require("gulp-typings")
},
merge2: require("merge2"),
projectinfo: require("projectinfo"),
sourceMapSupport: require("source-map-support").install(),
path: require("path"),
Q: require("q"),
shelljs: require("shelljs"),
smartcli: require("smartcli"),
smartenv: require("smartenv"),
smartfile: require("smartfile"),
typings: require("typings")
}; };
module.exports = plugins; exports.merge2 = require("merge2");
exports.projectinfo = require("projectinfo");
exports.sourceMapSupport = require("source-map-support").install();
exports.path = require("path");
exports.Q = require("q");
exports.shelljs = require("shelljs");
exports.smartci = require("smartci");
exports.smartcli = require("smartcli");
exports.smartenv = require("smartenv");
exports.smartfile = require("smartfile");
exports.smartpath = require("smartpath");

View File

@ -1,15 +1,48 @@
"use strict";
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var NpmtsConfigFile = require("./npmts.configfile"); var plugins = require("./npmts.plugins");
var NpmtsOptions = require("./npmts.options"); var NpmtsAssets = require("./npmts.assets");
var NpmtsClean = require("./npmts.clean");
var NpmtsCompile = require("./npmts.compile"); var NpmtsCompile = require("./npmts.compile");
var NpmtsConfigFile = require("./npmts.configfile");
var NpmtsInstall = require("./npmts.install");
var NpmtsJsdoc = require("./npmts.jsdoc"); var NpmtsJsdoc = require("./npmts.jsdoc");
var NpmtsOptions = require("./npmts.options");
var NpmtsPublish = require("./npmts.publish");
var NpmtsTests = require("./npmts.tests"); var NpmtsTests = require("./npmts.tests");
exports.run = function () { exports.run = function () {
var promisechain; var promisechain;
NpmtsConfigFile.run() NpmtsConfigFile.run()
.then(NpmtsOptions.run) .then(NpmtsOptions.run)
.then(NpmtsClean.run)
.then(NpmtsInstall.run)
.then(NpmtsCompile.run) .then(NpmtsCompile.run)
.then(NpmtsAssets.run)
.then(NpmtsJsdoc.run) .then(NpmtsJsdoc.run)
.then(NpmtsTests.run); .then(NpmtsTests.run)
.then(NpmtsPublish.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!");
}
});
return promisechain; return promisechain;
}; };

15
dist/npmts.publish.js vendored Normal file
View File

@ -0,0 +1,15 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var NpmtsTests = require("./npmts.tests");
var NpmtsJsdoc = require("./npmts.jsdoc");
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
var promiseArray = [];
config.coveralls ? promiseArray.push(NpmtsTests.publishCoverage(configArg)) : void (0);
config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void (0);
promiseArray.length === 0 ? plugins.beautylog.info("Did not publish anything!") : void (0);
plugins.Q.all(promiseArray).then(done.resolve);
return done.promise;
};

32
dist/npmts.tests.js vendored
View File

@ -1,6 +1,18 @@
"use strict";
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins"); var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths"); var paths = require("./npmts.paths");
exports.publishCoverage = function (configArg) {
var done = plugins.Q.defer();
plugins.beautylog.log("now uploading coverage data to coveralls");
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
.pipe(plugins.g.coveralls())
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("Coverage data has been uploaded to Coveralls!");
done.resolve(configArg);
}, "atEnd"));
return done.promise;
};
exports.run = function (configArg) { exports.run = function (configArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
var config = configArg; var config = configArg;
@ -17,22 +29,14 @@ exports.run = function (configArg) {
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } })); .pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
return stream; return stream;
}; };
var coveralls = function () { plugins.beautylog.log("now starting tests");
plugins.beautylog.log("now uploading coverage data to coveralls"); console.log("--------------------------------------------------\n" +
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")]) "******************* TESTS: **********************\n" +
.pipe(plugins.g.coveralls()); "--------------------------------------------------");
return stream;
};
istanbul().on("finish", function () { istanbul().on("finish", function () {
mocha().on("finish", function () { mocha().on("finish", function () {
if (plugins.smartenv.getEnv().isTravis && config.coveralls) { plugins.beautylog.ok("Tests have passed!");
coveralls().on("finish", function () { done.resolve(config);
done.resolve(config);
});
}
else {
done.resolve(config);
}
}); });
}); });
return done.promise; return done.promise;

View File

@ -1,6 +1,6 @@
{ {
"name": "npmts", "name": "npmts",
"version": "3.3.1", "version": "3.6.7",
"description": "write npm modules with TypeScript", "description": "write npm modules with TypeScript",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {
@ -26,29 +26,28 @@
"homepage": "https://github.com/pushrocks/npmts#readme", "homepage": "https://github.com/pushrocks/npmts#readme",
"dependencies": { "dependencies": {
"beautylog": "3.1.2", "beautylog": "3.1.2",
"fs-extra": "^0.26.5", "fs-extra": "^0.26.7",
"gulp": "3.9.1", "gulp": "3.9.1",
"gulp-concat": "^2.6.0", "gulp-concat": "^2.6.0",
"gulp-coveralls": "^0.1.4", "gulp-coveralls": "^0.1.4",
"gulp-function": "^1.1.1", "gulp-function": "^1.1.1",
"gulp-if": "^2.0.0", "gulp-if": "^2.0.0",
"gulp-istanbul": "^0.10.3", "gulp-istanbul": "^0.10.3",
"gulp-jsdoc3": "^0.2.0", "gulp-jsdoc3": "^0.2.1",
"gulp-mocha": "^2.2.0", "gulp-mocha": "^2.2.0",
"gulp-sourcemaps": "^1.6.0", "gulp-sourcemaps": "^1.6.0",
"gulp-typescript": "2.11.0", "gulp-typescript": "2.12.1",
"gulp-typings": "1.1.0", "gulp-typings": "1.3.0",
"merge2": "1.0.1", "merge2": "1.0.1",
"projectinfo": "1.0.1", "projectinfo": "1.0.1",
"q": "^1.4.1", "q": "^1.4.1",
"shelljs": "^0.6.0", "shelljs": "^0.6.0",
"smartci": "0.0.1",
"smartcli": "0.0.11", "smartcli": "0.0.11",
"smartenv": "1.1.0", "smartenv": "1.2.0",
"smartfile": "0.0.11", "smartfile": "2.2.0",
"source-map-support": "^0.4.0", "smartpath": "3.0.1",
"typings": "^0.6.8" "source-map-support": "^0.4.0"
}, },
"devDependencies": { "devDependencies": {}
"gulp-typings": "^1.1.0"
}
} }

3
test/assets/custom.js Normal file
View File

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

View File

@ -4,10 +4,14 @@
"./customdir/*.ts":"./" "./customdir/*.ts":"./"
}, },
"typings":[ "typings":[
"./ts", "./ts/typings.json",
"./subts1/", "./subts1/typings.json",
"./subts2/", "./subts2/typings.json",
"./customdir" "./customdir/typings.json"
], ],
"coveralls":true "coveralls":true,
"docs": {
"publish":true
},
"cli":true
} }

View File

@ -1,5 +1,4 @@
/// <reference path="../ts/typings/main.d.ts" /> /// <reference path="../ts/typings/main.d.ts" />
console.log("**** starting test ****");
var testplugin = require("../dist/index.js"); var testplugin = require("../dist/index.js");
describe("testplugins", function () { describe("testplugins", function () {
describe(".logSomething", function () { describe(".logSomething", function () {
@ -9,4 +8,4 @@ describe("testplugins", function () {
}); });
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELE9BQU8sQ0FBQyxHQUFHLENBQUMseUJBQXlCLENBQUMsQ0FBQztBQUN2QyxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQztBQUM3QyxRQUFRLENBQUMsYUFBYSxFQUFDO0lBQ25CLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsRUFBRSxDQUFDLHNCQUFzQixFQUFDO1lBQ3RCLFVBQVUsQ0FBQyxZQUFZLEVBQUUsQ0FBQTtRQUM3QixDQUFDLENBQUMsQ0FBQztJQUNQLENBQUMsQ0FBQyxDQUFDO0FBQ1AsQ0FBQyxDQUFDLENBQUMiLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuLi90cy90eXBpbmdzL21haW4uZC50c1wiIC8+XG5jb25zb2xlLmxvZyhcIioqKiogc3RhcnRpbmcgdGVzdCAqKioqXCIpO1xudmFyIHRlc3RwbHVnaW4gPSByZXF1aXJlKFwiLi4vZGlzdC9pbmRleC5qc1wiKTtcbmRlc2NyaWJlKFwidGVzdHBsdWdpbnNcIixmdW5jdGlvbigpe1xuICAgIGRlc2NyaWJlKFwiLmxvZ1NvbWV0aGluZ1wiLGZ1bmN0aW9uKCl7XG4gICAgICAgIGl0KFwic2hvdWxkIGxvZyBzb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgdGVzdHBsdWdpbi5sb2dTb21ldGhpbmcoKVxuICAgICAgICB9KTtcbiAgICB9KTtcbn0pOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ== //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksVUFBVSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzdDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixFQUFFLENBQUMsc0JBQXNCLEVBQUM7WUFDdEIsVUFBVSxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQzdCLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbnZhciB0ZXN0cGx1Z2luID0gcmVxdWlyZShcIi4uL2Rpc3QvaW5kZXguanNcIik7XG5kZXNjcmliZShcInRlc3RwbHVnaW5zXCIsZnVuY3Rpb24oKXtcbiAgICBkZXNjcmliZShcIi5sb2dTb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICBpdChcInNob3VsZCBsb2cgc29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIHRlc3RwbHVnaW4ubG9nU29tZXRoaW5nKClcbiAgICAgICAgfSk7XG4gICAgfSk7XG59KTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

View File

@ -1 +1 @@
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AACvC,IAAI,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC7C,QAAQ,CAAC,aAAa,EAAC;IACnB,QAAQ,CAAC,eAAe,EAAC;QACrB,EAAE,CAAC,sBAAsB,EAAC;YACtB,UAAU,CAAC,YAAY,EAAE,CAAA;QAC7B,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"} {"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC7C,QAAQ,CAAC,aAAa,EAAC;IACnB,QAAQ,CAAC,eAAe,EAAC;QACrB,EAAE,CAAC,sBAAsB,EAAC;YACtB,UAAU,CAAC,YAAY,EAAE,CAAA;QAC7B,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

View File

@ -1,5 +1,4 @@
/// <reference path="../ts/typings/main.d.ts" /> /// <reference path="../ts/typings/main.d.ts" />
console.log("**** starting test ****");
var testplugin = require("../dist/index.js"); var testplugin = require("../dist/index.js");
describe("testplugins",function(){ describe("testplugins",function(){
describe(".logSomething",function(){ describe(".logSomething",function(){

View File

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

3
test/assets/tsfile1.js Normal file
View File

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

View File

@ -3,4 +3,11 @@ console.log("**** starting NPMTS ****");
import plugins = require("./npmts.plugins"); import plugins = require("./npmts.plugins");
import promisechain = require("./npmts.promisechain"); import promisechain = require("./npmts.promisechain");
plugins.beautylog.figletSync("NPMTS"); plugins.beautylog.figletSync("NPMTS");
promisechain.run();
try {
promisechain.run();
}
catch(err){
console.log(err);
}

17
ts/npmts.assets.ts Normal file
View File

@ -0,0 +1,17 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
export var run = function(configArg){
let done = plugins.Q.defer();
let config = configArg;
plugins.beautylog.log("now looking at required assets");
if(config.cli == true){
plugins.smartfile.fsaction.copy(plugins.path.join(paths.npmtsAssetsDir,"cli.js"),paths.distDir);
plugins.beautylog.ok("CLI asset has been installed!");
done.resolve(config);
} else {
done.resolve(config);
}
return done.promise;
};

13
ts/npmts.clean.ts Normal file
View File

@ -0,0 +1,13 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
export let run = function(configArg){
plugins.beautylog.log("now cleaning up from previous builds");
let done = plugins.Q.defer();
plugins.smartfile.fsaction.remove(paths.distDir)
.then(function(){
done.resolve(configArg);
});
return done.promise;
};

View File

@ -4,89 +4,66 @@ import paths = require("./npmts.paths");
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;
plugins.beautylog.log("now running custom tasks"); plugins.beautylog.log("now compiling " + "TypeScript".yellow);
var moduleStream = plugins.merge2({end: false}); var moduleStream = plugins.merge2({end: false});
/* -------------------------------------------------
* ----------- first install typings ---------------
* ----------------------------------------------- */
var typingsDone = plugins.Q.defer();
var typingsCounter:number = 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: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 * ----------- compile TypeScript --------------------------
.pipe(plugins.g.typescript({ * ----------------------------------------------- */
out: outputName, for (var key in config.ts) {
target: "ES5", var outputPathIsDir:boolean;
module: "commonjs" try {
})) if(plugins.fs.statSync(plugins.path.join(paths.cwd,config.ts[key])).isDirectory()){
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file outputPathIsDir = true;
//.pipe(plugins.g.header('#!/usr/bin/env node\n\n')) }
.pipe(plugins.gulp.dest(outputDir));
moduleStream.add(stream);
} }
moduleStream.on("queueDrain",function(){ catch(err) {
plugins.beautylog.success("custom TypeScript installed successfully"); outputPathIsDir = false;
moduleStream.on("finish",function(){ }
done.resolve(config); //do some evaluation of the environment
}); var outputNameSpecified:boolean = (
moduleStream.end(); !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.ok("TypeScript has been compiled!");
moduleStream.on("finish",function(){
done.resolve(config);
}); });
moduleStream.end();
}); });
/*==================== END TYPESCRIPT =====================*/
return done.promise; return done.promise;
}; };

View File

@ -7,7 +7,7 @@ export var run = function(){
var configPath = plugins.path.join(paths.cwd,"npmts.json"); var configPath = plugins.path.join(paths.cwd,"npmts.json");
if(plugins.smartfile.checks.fileExistsSync(configPath)){ if(plugins.smartfile.checks.fileExistsSync(configPath)){
plugins.beautylog.info("npmts.json".blue + " config file found!"); plugins.beautylog.info("npmts.json".blue + " config file found!");
config = plugins.smartfile.readFileToObject(configPath); config = plugins.smartfile.local.toObjectSync(configPath);
switch (config.mode){ switch (config.mode){
case "default": case "default":
case "custom": case "custom":
@ -16,6 +16,7 @@ export var run = function(){
break; break;
default: default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red); plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
}; };
} else { } else {
plugins.beautylog.log("no config file found: so mode is " + "default".yellow); plugins.beautylog.log("no config file found: so mode is " + "default".yellow);

19
ts/npmts.install.ts Normal file
View File

@ -0,0 +1,19 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
export var run = function(configArg){
var config = configArg;
var done = plugins.Q.defer();
/* -------------------------------------------------
* ----------- install typings ---------------
* ----------------------------------------------- */
plugins.beautylog.log("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 have been installed!");
done.resolve(config);
},"atEnd"));
return done.promise;
};

View File

@ -2,8 +2,8 @@
import plugins = require("./npmts.plugins"); import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths"); import paths = require("./npmts.paths");
var genJsdoc = function(configArg){ let genJsdoc = function(configArg){
var done = plugins.Q.defer(); let done = plugins.Q.defer();
plugins.beautylog.log("now generating " + "JsDoc documentation".blue); plugins.beautylog.log("now generating " + "JsDoc documentation".blue);
plugins.gulp.src([ plugins.gulp.src([
plugins.path.join(paths.cwd,"README.md"), plugins.path.join(paths.cwd,"README.md"),
@ -14,21 +14,22 @@ var genJsdoc = function(configArg){
destination: paths.docsDir destination: paths.docsDir
} }
}, function(){ }, function(){
plugins.beautylog.ok("JsDoc documentation has been generated!");
done.resolve(configArg) done.resolve(configArg)
})); }));
return done.promise; return done.promise;
}; };
var publishDocs = function(configArg){ export let publishDocs = function(configArg){
var done = plugins.Q.defer(); let done = plugins.Q.defer();
var gitUrl = plugins.projectinfo.npm( let gitUrl = plugins.projectinfo.npm(
paths.cwd, paths.cwd,
{ {
gitAccessToken:process.env.GITHUB_TOKEN gitAccessToken:process.env.GITHUB_TOKEN
} }
).git.httpsUrl; ).git.httpsUrl;
var deployScript = "" let deployScript = ""
+ "cd " + paths.docsDir + " " + "cd " + paths.docsDir + " "
+ "&& git init " + "> /dev/null 2>&1 " + "&& git init " + "> /dev/null 2>&1 "
+ "&& git config user.name \"TRAVIS CI\" " + "> /dev/null 2>&1 " + "&& git config user.name \"TRAVIS CI\" " + "> /dev/null 2>&1 "
@ -39,28 +40,25 @@ var publishDocs = function(configArg){
+ "\"" + gitUrl + "\" " + "\"" + gitUrl + "\" "
+ "master:gh-pages " + "> /dev/null 2>&1"; + "master:gh-pages " + "> /dev/null 2>&1";
if(plugins.smartenv.getEnv().isTravis){
plugins.beautylog.log("now publishing docs to GitHub") plugins.beautylog.log("now publishing JsDoc documentation to GitHub");
if (!plugins.shelljs.which('git')) { if (!plugins.shelljs.which('git')) {
plugins.beautylog.error('Git is not installed'); plugins.beautylog.error('Git is not installed!');
plugins.shelljs.exit(1); plugins.shelljs.exit(1);
} else if (plugins.shelljs.exec(deployScript).code !== 0) { } else if (plugins.shelljs.exec(deployScript).code !== 0) {
plugins.beautylog.error('Error: Git failed'); plugins.beautylog.error('Git failed!');
plugins.shelljs.exit(1); plugins.shelljs.exit(1);
}
plugins.beautylog.success("Docs have been deployed to GitHub");
done.resolve(configArg);
} else {
done.resolve(configArg);
} }
plugins.beautylog.ok("JsDoc documentation has been deployed to GitHub!");
done.resolve(configArg);
return done.promise; return done.promise;
}; };
export var run = function(configArg){ export let run = function(configArg){
var done = plugins.Q.defer(); let done = plugins.Q.defer();
genJsdoc(configArg) genJsdoc(configArg)
.then(publishDocs)
.then(done.resolve); .then(done.resolve);
return done.promise; return done.promise;
}; };

View File

@ -1,23 +1,50 @@
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins"); import plugins = require("./npmts.plugins");
export let isRelease = function():boolean {
return plugins.smartci.check.isCi()
&& plugins.smartci.check.isTaggedCommit();
};
export let doPublish = function():boolean {
return isRelease()
&& plugins.smartci.get.subJobNumber() == 1;
};
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"){
config.coveralls = false; plugins.beautylog.log("now determining build options");
}
//handle default mode
if (config.mode == "default"){ if (config.mode == "default"){
config.typings = [ config.typings = [
"./ts/" "./ts/typings.json"
]; ];
config.ts = { config.ts = {
["./ts/**/*.ts"]: "./dist/", ["./ts/**/*.ts"]: "./dist/",
["./test/test.ts"]: "./test/" ["./test/test.ts"]: "./test/"
}; };
config.test = ["./index.js"]; config.test = ["./index.js"];
done.resolve(config);
} else {
done.resolve(config);
} }
// handle state of current build
isRelease() ? plugins.beautylog.info("All right: This is a RELEASE build!")
: plugins.beautylog.info("NOT A RELEASE build!");
isRelease() && doPublish() ? plugins.beautylog.info("All right: This is the first subBuild, so this one publishes coverage and docs when tests succeed!")
: plugins.beautylog.info("We are not publishing anything!");
// handle coveralls
config.coveralls ? void(0) : config.coveralls = false;
doPublish() ? void(0) : config.coveralls = false;
// handle docs
config.docs ? void(0) : config.docs = {};
config.docs.publish ? void(0) : config.docs.publish = false;
doPublish() ? void(0) : config.docs.publish = false;
done.resolve(config);
return done.promise; return done.promise;
}; };

View File

@ -9,6 +9,8 @@ paths.distDir = plugins.path.join(paths.cwd,"dist/");
paths.docsDir = plugins.path.join(paths.cwd,"docs/"); paths.docsDir = plugins.path.join(paths.cwd,"docs/");
paths.testDir = plugins.path.join(paths.cwd,"test/"); paths.testDir = plugins.path.join(paths.cwd,"test/");
paths.npmtsAssetsDir = plugins.path.join(__dirname,"../assets/");
//Files //Files
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");

View File

@ -1,27 +1,26 @@
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var plugins = { export let beautylog = require("beautylog");
beautylog: require("beautylog"), export let fs = require("fs-extra");
fs: require("fs-extra"), export let gulp = require("gulp");
gulp: require("gulp"), export let g = {
g: { coveralls: require("gulp-coveralls"),
coveralls: require("gulp-coveralls"), gFunction: require("gulp-function"),
gFunction: require("gulp-function"), istanbul: require("gulp-istanbul"),
istanbul: require("gulp-istanbul"), jsdoc3: require("gulp-jsdoc3"),
jsdoc3: require("gulp-jsdoc3"), mocha: require("gulp-mocha"),
mocha: require("gulp-mocha"), sourcemaps: require("gulp-sourcemaps"),
sourcemaps: require("gulp-sourcemaps"), typescript: require("gulp-typescript"),
typescript: require("gulp-typescript") typings: require("gulp-typings")
},
merge2: require("merge2"),
projectinfo: require("projectinfo"),
sourceMapSupport:require("source-map-support").install(),
path: require("path"),
Q:require("q"),
shelljs: require("shelljs"),
smartcli: require("smartcli"),
smartenv: require("smartenv"),
smartfile: require("smartfile"),
typings: require("typings")
}; };
export = plugins; export let merge2 = require("merge2");
export let projectinfo = require("projectinfo");
export let sourceMapSupport = require("source-map-support").install();
export let path = require("path");
export let Q = require("q");
export let shelljs = require("shelljs");
export let smartci = require("smartci");
export let smartcli = require("smartcli");
export let smartenv = require("smartenv");
export let smartfile = require("smartfile");
export let smartpath = require("smartpath");

View File

@ -1,15 +1,49 @@
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
import NpmtsConfigFile = require("./npmts.configfile"); import plugins = require("./npmts.plugins");
import NpmtsOptions = require("./npmts.options");
import NpmtsAssets = require("./npmts.assets");
import NpmtsClean = require("./npmts.clean");
import NpmtsCompile = require("./npmts.compile"); import NpmtsCompile = require("./npmts.compile");
import NpmtsConfigFile = require("./npmts.configfile");
import NpmtsInstall = require("./npmts.install");
import NpmtsJsdoc = require("./npmts.jsdoc"); import NpmtsJsdoc = require("./npmts.jsdoc");
import NpmtsOptions = require("./npmts.options");
import NpmtsPublish = require("./npmts.publish");
import NpmtsTests = require("./npmts.tests"); import NpmtsTests = require("./npmts.tests");
export var run = function(){ export var run = function(){
var promisechain; var promisechain;
NpmtsConfigFile.run() NpmtsConfigFile.run()
.then(NpmtsOptions.run) .then(NpmtsOptions.run)
.then(NpmtsClean.run)
.then(NpmtsInstall.run)
.then(NpmtsCompile.run) .then(NpmtsCompile.run)
.then(NpmtsAssets.run)
.then(NpmtsJsdoc.run) .then(NpmtsJsdoc.run)
.then(NpmtsTests.run); .then(NpmtsTests.run)
.then(NpmtsPublish.run)
.then(function(configArg){
let 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!")
}
});
return promisechain; return promisechain;
}; };

19
ts/npmts.publish.ts Normal file
View File

@ -0,0 +1,19 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
import NpmtsTests = require("./npmts.tests");
import NpmtsJsdoc = require("./npmts.jsdoc");
export let run = function(configArg){
let done = plugins.Q.defer();
let config = configArg;
let promiseArray = [];
config.coveralls ? promiseArray.push(NpmtsTests.publishCoverage(configArg)) : void(0);
config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void(0);
promiseArray.length === 0 ? plugins.beautylog.info("Did not publish anything!") : void(0);
plugins.Q.all(promiseArray).then(done.resolve);
return done.promise;
};

View File

@ -1,6 +1,19 @@
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins"); import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths"); import paths = require("./npmts.paths");
export let publishCoverage = function(configArg){
let done = plugins.Q.defer();
plugins.beautylog.log("now uploading coverage data to coveralls");
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
.pipe(plugins.g.coveralls())
.pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("Coverage data has been uploaded to Coveralls!");
done.resolve(configArg);
},"atEnd"));
return done.promise;
};
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;
@ -23,22 +36,16 @@ export var run = function(configArg) {
return stream; return stream;
}; };
var coveralls = function(){ plugins.beautylog.log("now starting tests");
plugins.beautylog.log("now uploading coverage data to coveralls"); console.log(
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")]) "--------------------------------------------------\n" +
.pipe(plugins.g.coveralls()); "******************* TESTS: **********************\n" +
return stream; "--------------------------------------------------"
}; );
istanbul().on("finish",function(){ istanbul().on("finish",function(){
mocha().on("finish",function(){ mocha().on("finish",function(){
if(plugins.smartenv.getEnv().isTravis && config.coveralls){ plugins.beautylog.ok("Tests have passed!");
coveralls().on("finish",function(){ done.resolve(config);
done.resolve(config);
})
} else {
done.resolve(config);
}
}) })
}); });
return done.promise; return done.promise;