Compare commits

...

15 Commits

Author SHA1 Message Date
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
070385867e 3.3.1 2016-02-25 08:26:32 +01:00
e429eb8ae0 fix cli call 2016-02-25 08:26:00 +01:00
6045174edb 3.3.0 2016-02-23 20:02:18 +01:00
08dcdb2c9f now installing typings before compiling 2016-02-23 20:02:07 +01:00
44aa92c83c now completeley hiding git console output 2016-02-23 18:58:44 +01:00
e43541cf90 3.2.2 2016-02-23 18:35:36 +01:00
414e845b80 fix config traveling 2016-02-23 18:35:28 +01:00
c18eb85ec8 fixed repo path 2016-02-23 18:24:07 +01:00
3ae3598c96 update env vars 2016-02-23 18:10:03 +01:00
26eca7aa65 added GitHub Token again 2016-02-23 17:44:35 +01:00
48d9de65a0 3.2.1 2016-02-23 17:33:04 +01:00
31 changed files with 279 additions and 266 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

View File

@ -1,7 +1,7 @@
language: node_js language: node_js
node_js: node_js:
- "4.3.1" - 4.3.1
- "stable" - stable
deploy: deploy:
provider: npm provider: npm
email: npm@lossless.digital email: npm@lossless.digital
@ -10,3 +10,6 @@ deploy:
on: on:
tags: true tags: true
repo: pushrocks/npmts repo: pushrocks/npmts
env:
global:
secure: kPKBMnEKoC+K5dXpl11NhuK3LSp0c0fRO60Akj3QeQBjUWnVAcF0Ht30c31y0lnJaMEzXhmUIKdR7RQnlmw5be4TYGINzY7FD3Dcv7o+HO1ZQrkpMWSu46jF6ZJer9moGjZ8e0rX8wZyB9SqsXYlwWRzqvxfOVxQfTvU3BEnJKHbhq+R5JMJ8dwLBPNTJKMWKq85KNsjo3ap0BjxdBUoRLzvrn31VOPH30BkvmLGc5YiIz5QmITll/T2wmQKYTNT2qDlEJ729B8pYa3eNlCNi89AxsLDGCmEoJAVrPsyw5g+gAyBqZ1GRULy83UJbELUq7cse3MRLMSwCAm4f0INRAuqcyiKYJ4+LHd0NwKrFQ/dQ0pvyBTbbEjNemXaakkWH7S6F03UvF+u+tiQ7C97XH0CRsseGlm36zCkAClEhtWVWA4U0Q5c6zqRAAOYOI0xquXalRKPTJe7fCYewp2eqmlp8drt8MxancyKI/ynXNoR5vGFzDTSRoPjTlaYQPmbiH4+Nd5+6Qoj94PEIqghebIPDQo3C7vWts4WGccux5b2q524UgB63hjJQA6+GQOo1q4RibouS6WScn8/tW/ZOEP+sNhDfkeiZUIjye+Q3PyzonGHefgSQ8wBbsc8LOX0cKUcEFWr14nhdQ9ZeW+hrSSF04TbM4zGJPGcKhmT2UU=

2
assets/cli.js Normal file
View File

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

View File

@ -4,7 +4,7 @@ var plugins = {
gulp: require("gulp"), gulp: require("gulp"),
g:{ g:{
typescript: require("gulp-typescript"), typescript: require("gulp-typescript"),
header: require("gulp-header") typings:require("gulp-typings")
}, },
mergeStream: require("merge2"), mergeStream: require("merge2"),
path: require("path") path: require("path")
@ -18,7 +18,13 @@ paths = {
plugins.beautylog.log('now compiling NPMTS'); plugins.beautylog.log('now compiling NPMTS');
plugins.gulp.task('indexTS', function() { plugins.gulp.task("typings",function(){
var stream = plugins.gulp.src(plugins.path.join(paths.packageBase,"ts/typings.json"))
.pipe(plugins.g.typings());
return stream;
});
plugins.gulp.task("TS",["typings"], function() {
var stream = plugins.gulp.src([ var stream = plugins.gulp.src([
plugins.path.join(paths.packageBase,'ts/**/*.ts'), plugins.path.join(paths.packageBase,'ts/**/*.ts'),
"!" + plugins.path.join(paths.packageBase,'ts/typings/**/*.d.ts') "!" + plugins.path.join(paths.packageBase,'ts/typings/**/*.d.ts')
@ -27,12 +33,16 @@ plugins.gulp.task('indexTS', function() {
target:"ES5", target:"ES5",
module:"commonjs" module:"commonjs"
})) }))
.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest(plugins.path.join(paths.packageBase, 'dist/'))); .pipe(plugins.gulp.dest(plugins.path.join(paths.packageBase, 'dist/')));
return stream; return stream;
}); });
plugins.gulp.task('default',['indexTS'], function() { plugins.gulp.task("CLI",function(){
var stream = plugins.gulp.src(plugins.path.join(paths.packageBase,"assets/cli.js"))
.pipe(plugins.gulp.dest(plugins.path.join(paths.packageBase, 'dist/')))
});
plugins.gulp.task('default',['TS',"CLI"], function() {
plugins.beautylog.success('Typescript compiled'); plugins.beautylog.success('Typescript compiled');
}); });

3
dist/cli.js vendored
View File

@ -1,3 +1,2 @@
#!/usr/bin/env node #!/usr/bin/env node
var index = require("./index.js");
/// <reference path="./typings/main.d.ts" />

3
dist/index.js vendored
View File

@ -1,5 +1,4 @@
#!/usr/bin/env node "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");

2
dist/npmts.cli.js vendored
View File

@ -1,3 +1 @@
#!/usr/bin/env node
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />

123
dist/npmts.compile.js vendored
View File

@ -1,91 +1,62 @@
#!/usr/bin/env node "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 is compiled!");
moduleStream.on("finish", function () {
done.resolve(config);
}); });
moduleStream.end();
}); });
/*==================== END TYPESCRIPT =====================*/
return done.promise; return done.promise;
}; };

View File

@ -1,5 +1,4 @@
#!/usr/bin/env node "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");
@ -18,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.absolute(config.typings, paths.cwd);
plugins.gulp.src(absoluteTypingsArray)
.pipe(plugins.g.typings())
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("typings are installed!");
done.resolve(config);
}, "atEnd"));
return done.promise;
};

55
dist/npmts.jsdoc.js vendored
View File

@ -1,9 +1,8 @@
#!/usr/bin/env node "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");
var genJsdoc = function () { var genJsdoc = function (configArg) {
var done = plugins.Q.defer(); var 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([
@ -14,31 +13,28 @@ var genJsdoc = function () {
opts: { opts: {
destination: paths.docsDir destination: paths.docsDir
} }
}, done.resolve)); }, function () {
plugins.beautylog.ok("JsDoc has been generated!");
done.resolve(configArg);
}));
return done.promise; return done.promise;
}; };
var publishDocs = function () { var publishDocs = function (configArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
try { var gitUrl = plugins.projectinfo.npm(paths.cwd, {
var gitUrl = plugins.projectinfo.npm(paths.cwd, { gitAccessToken: process.env.GITHUB_TOKEN
gitAccessToken: process.env.GITHUB_TOKEN }).git.httpsUrl;
}).git.httpsUrl; var deployScript = ""
var deployScript = "" + "cd " + paths.docsDir + " "
+ "cd " + paths.docsDir + " " + "&& git init " + "> /dev/null 2>&1 "
+ "&& git init " + "&& git config user.name \"TRAVIS CI\" " + "> /dev/null 2>&1 "
+ "&& git config user.name \"TRAVIS CI\" " + "&& git config user.email \"travis@shipzone.io\" " + "> /dev/null 2>&1 "
+ "&& git config user.email \"travis@shipzone.io\" " + "&& git add . " + "> /dev/null 2>&1 "
+ "&& git add . " + "&& git commit -m \"Deploy to GitHub Pages\" " + "> /dev/null 2>&1 "
+ "&& git commit -m \"Deploy to GitHub Pages\" " + "&& git push --force --quiet "
+ "&& git push --force --quiet " + "\"" + gitUrl + "\" "
+ "\"" + gitUrl + "\" " + "master:gh-pages " + "> /dev/null 2>&1";
+ "master:gh-pages " if (plugins.smartenv.getEnv().isTravis && configArg.docs && configArg.docs.publish) {
+ "> /dev/null 2>&1";
}
catch (err) {
console.log(err);
}
if (plugins.smartenv.getEnv().isTravis) {
plugins.beautylog.log("now publishing docs 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');
@ -48,16 +44,17 @@ var publishDocs = function () {
plugins.beautylog.error('Error: Git failed'); plugins.beautylog.error('Error: Git failed');
plugins.shelljs.exit(1); plugins.shelljs.exit(1);
} }
done.resolve(); plugins.beautylog.ok("JsDoc has been deployed to GitHub!");
done.resolve(configArg);
} }
else { else {
done.resolve(); done.resolve(configArg);
} }
return done.promise; return done.promise;
}; };
exports.run = function () { exports.run = function (configArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
genJsdoc() genJsdoc(configArg)
.then(publishDocs) .then(publishDocs)
.then(done.resolve); .then(done.resolve);
return done.promise; return done.promise;

View File

@ -1,5 +1,4 @@
#!/usr/bin/env node "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.run = function (configArg) { exports.run = function (configArg) {
@ -10,7 +9,7 @@ exports.run = function (configArg) {
} }
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/",

3
dist/npmts.paths.js vendored
View File

@ -1,5 +1,4 @@
#!/usr/bin/env node "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 = {};

View File

@ -1,5 +1,4 @@
#!/usr/bin/env node "use strict";
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var plugins = { var plugins = {
beautylog: require("beautylog"), beautylog: require("beautylog"),
@ -12,7 +11,8 @@ var plugins = {
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"), merge2: require("merge2"),
projectinfo: require("projectinfo"), projectinfo: require("projectinfo"),
@ -23,6 +23,6 @@ var plugins = {
smartcli: require("smartcli"), smartcli: require("smartcli"),
smartenv: require("smartenv"), smartenv: require("smartenv"),
smartfile: require("smartfile"), smartfile: require("smartfile"),
typings: require("typings") smartpath: require("smartpath")
}; };
module.exports = plugins; module.exports = plugins;

View File

@ -1,8 +1,8 @@
#!/usr/bin/env node "use strict";
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
var NpmtsConfigFile = require("./npmts.configfile"); var NpmtsConfigFile = require("./npmts.configfile");
var NpmtsOptions = require("./npmts.options"); var NpmtsOptions = require("./npmts.options");
var NpmtsInstall = require("./npmts.install");
var NpmtsCompile = require("./npmts.compile"); var NpmtsCompile = require("./npmts.compile");
var NpmtsJsdoc = require("./npmts.jsdoc"); var NpmtsJsdoc = require("./npmts.jsdoc");
var NpmtsTests = require("./npmts.tests"); var NpmtsTests = require("./npmts.tests");
@ -10,6 +10,7 @@ exports.run = function () {
var promisechain; var promisechain;
NpmtsConfigFile.run() NpmtsConfigFile.run()
.then(NpmtsOptions.run) .then(NpmtsOptions.run)
.then(NpmtsInstall.run)
.then(NpmtsCompile.run) .then(NpmtsCompile.run)
.then(NpmtsJsdoc.run) .then(NpmtsJsdoc.run)
.then(NpmtsTests.run); .then(NpmtsTests.run);

10
dist/npmts.tests.js vendored
View File

@ -1,5 +1,4 @@
#!/usr/bin/env node "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");
@ -22,9 +21,13 @@ exports.run = function (configArg) {
var coveralls = function () { var coveralls = function () {
plugins.beautylog.log("now uploading coverage data to coveralls"); plugins.beautylog.log("now uploading coverage data to coveralls");
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())
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("coverage data has beend uploaded Coveralls!");
}, "atEnd"));
return stream; return stream;
}; };
plugins.beautylog.log("now starting tests");
istanbul().on("finish", function () { istanbul().on("finish", function () {
mocha().on("finish", function () { mocha().on("finish", function () {
if (plugins.smartenv.getEnv().isTravis && config.coveralls) { if (plugins.smartenv.getEnv().isTravis && config.coveralls) {
@ -33,6 +36,7 @@ exports.run = function (configArg) {
}); });
} }
else { else {
plugins.beautylog.ok("Tests have passed!");
done.resolve(config); done.resolve(config);
} }
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "npmts", "name": "npmts",
"version": "3.2.0", "version": "3.4.0",
"description": "write npm modules with TypeScript", "description": "write npm modules with TypeScript",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {
@ -31,25 +31,24 @@
"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-header": "^1.7.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.0",
"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.1.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",
"smartcli": "0.0.11", "smartcli": "0.0.11",
"smartenv": "1.1.0", "smartenv": "1.2.0",
"smartfile": "0.0.11", "smartfile": "0.0.11",
"source-map-support": "^0.4.0", "smartpath": "2.1.0",
"typings": "^0.6.8" "source-map-support": "^0.4.0"
}, },
"devDependencies": { "devDependencies": {
"gulp-header": "^1.7.1" "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

@ -1,13 +1,16 @@
{ {
"mode":"default", "mode":"custom",
"ts":{ "ts":{
"./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
}
} }

View File

@ -5,7 +5,7 @@
"main": "index.js", "main": "index.js",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/sometest/somerepo.git" "url": "git+https://github.com/pushrocks/npmts.git"
}, },
"scripts": { "scripts": {
"test": "(npmts)" "test": "(npmts)"

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

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

View File

@ -1 +0,0 @@
/// <reference path="./typings/main.d.ts" />

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 is compiled!");
moduleStream.on("finish",function(){
done.resolve(config);
}); });
moduleStream.end();
}); });
/*==================== END TYPESCRIPT =====================*/
return done.promise; return done.promise;
}; };

View File

@ -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);
let absoluteTypingsArray = plugins.smartpath.absolute(config.typings,paths.cwd);
plugins.gulp.src(absoluteTypingsArray)
.pipe(plugins.g.typings())
.pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("typings are installed!");
done.resolve(config);
},"atEnd"));
return done.promise;
};

View File

@ -2,7 +2,7 @@
import plugins = require("./npmts.plugins"); import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths"); import paths = require("./npmts.paths");
var genJsdoc = function(){ var genJsdoc = function(configArg){
var done = plugins.Q.defer(); var 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([
@ -13,38 +13,35 @@ var genJsdoc = function(){
opts: { opts: {
destination: paths.docsDir destination: paths.docsDir
} }
}, done.resolve)); }, function(){
plugins.beautylog.ok("JsDoc has been generated!");
done.resolve(configArg)
}));
return done.promise; return done.promise;
}; };
var publishDocs = function(){ var publishDocs = function(configArg){
var done = plugins.Q.defer(); var done = plugins.Q.defer();
try { var gitUrl = plugins.projectinfo.npm(
var gitUrl = plugins.projectinfo.npm( paths.cwd,
paths.cwd, {
{ gitAccessToken:process.env.GITHUB_TOKEN
gitAccessToken:process.env.GITHUB_TOKEN }
} ).git.httpsUrl;
).git.httpsUrl;
var deployScript = "" var deployScript = ""
+ "cd " + paths.docsDir + " " + "cd " + paths.docsDir + " "
+ "&& git init " + "&& git init " + "> /dev/null 2>&1 "
+ "&& git config user.name \"TRAVIS CI\" " + "&& git config user.name \"TRAVIS CI\" " + "> /dev/null 2>&1 "
+ "&& git config user.email \"travis@shipzone.io\" " + "&& git config user.email \"travis@shipzone.io\" " + "> /dev/null 2>&1 "
+ "&& git add . " + "&& git add . " + "> /dev/null 2>&1 "
+ "&& git commit -m \"Deploy to GitHub Pages\" " + "&& git commit -m \"Deploy to GitHub Pages\" " + "> /dev/null 2>&1 "
+ "&& git push --force --quiet " + "&& git push --force --quiet "
+ "\"" + gitUrl + "\" " + "\"" + gitUrl + "\" "
+ "master:gh-pages " + "master:gh-pages " + "> /dev/null 2>&1";
+ "> /dev/null 2>&1";
}
catch (err){
console.log(err);
}
if(plugins.smartenv.getEnv().isTravis){ if(plugins.smartenv.getEnv().isTravis && configArg.docs && configArg.docs.publish){
plugins.beautylog.log("now publishing docs 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);
@ -52,17 +49,18 @@ var publishDocs = function(){
plugins.beautylog.error('Error: Git failed'); plugins.beautylog.error('Error: Git failed');
plugins.shelljs.exit(1); plugins.shelljs.exit(1);
} }
done.resolve(); plugins.beautylog.ok("JsDoc has been deployed to GitHub!");
done.resolve(configArg);
} else { } else {
done.resolve(); done.resolve(configArg);
} }
return done.promise; return done.promise;
}; };
export var run = function(){ export var run = function(configArg){
var done = plugins.Q.defer(); var done = plugins.Q.defer();
genJsdoc() genJsdoc(configArg)
.then(publishDocs) .then(publishDocs)
.then(done.resolve); .then(done.resolve);
return done.promise; return done.promise;

View File

@ -8,7 +8,7 @@ export var run = function(configArg){
} }
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/",

View File

@ -10,7 +10,8 @@ var plugins = {
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"), merge2: require("merge2"),
@ -22,6 +23,6 @@ var plugins = {
smartcli: require("smartcli"), smartcli: require("smartcli"),
smartenv: require("smartenv"), smartenv: require("smartenv"),
smartfile: require("smartfile"), smartfile: require("smartfile"),
typings: require("typings") smartpath: require("smartpath")
}; };
export = plugins; export = plugins;

View File

@ -1,6 +1,7 @@
/// <reference path="./typings/main.d.ts" /> /// <reference path="./typings/main.d.ts" />
import NpmtsConfigFile = require("./npmts.configfile"); import NpmtsConfigFile = require("./npmts.configfile");
import NpmtsOptions = require("./npmts.options"); import NpmtsOptions = require("./npmts.options");
import NpmtsInstall = require("./npmts.install");
import NpmtsCompile = require("./npmts.compile"); import NpmtsCompile = require("./npmts.compile");
import NpmtsJsdoc = require("./npmts.jsdoc"); import NpmtsJsdoc = require("./npmts.jsdoc");
import NpmtsTests = require("./npmts.tests"); import NpmtsTests = require("./npmts.tests");
@ -8,6 +9,7 @@ export var run = function(){
var promisechain; var promisechain;
NpmtsConfigFile.run() NpmtsConfigFile.run()
.then(NpmtsOptions.run) .then(NpmtsOptions.run)
.then(NpmtsInstall.run)
.then(NpmtsCompile.run) .then(NpmtsCompile.run)
.then(NpmtsJsdoc.run) .then(NpmtsJsdoc.run)
.then(NpmtsTests.run); .then(NpmtsTests.run);

View File

@ -26,10 +26,14 @@ export var run = function(configArg) {
var coveralls = function(){ var coveralls = function(){
plugins.beautylog.log("now uploading coverage data to coveralls"); plugins.beautylog.log("now uploading coverage data to coveralls");
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())
.pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("coverage data has beend uploaded Coveralls!");
},"atEnd"));
return stream; return stream;
}; };
plugins.beautylog.log("now starting tests");
istanbul().on("finish",function(){ istanbul().on("finish",function(){
mocha().on("finish",function(){ mocha().on("finish",function(){
if(plugins.smartenv.getEnv().isTravis && config.coveralls){ if(plugins.smartenv.getEnv().isTravis && config.coveralls){
@ -37,6 +41,7 @@ export var run = function(configArg) {
done.resolve(config); done.resolve(config);
}) })
} else { } else {
plugins.beautylog.ok("Tests have passed!");
done.resolve(config); done.resolve(config);
} }
}) })