Compare commits

...

20 Commits

Author SHA1 Message Date
5d8ce3f227 2.1.0 2016-02-04 20:41:46 +01:00
de4bbaed9f now accepts config file 2016-02-04 20:41:34 +01:00
7d18e92ff1 2.0.3 2016-02-02 15:20:05 +01:00
634763c03f update beautylog 2016-02-02 15:19:48 +01:00
3352165436 2.0.2 2016-02-01 02:07:50 +01:00
6c57a4703f fix timing error caused by not returning stream 2016-02-01 02:07:41 +01:00
822734e545 2.0.1 2016-02-01 00:24:17 +01:00
8dcbe98c60 now running mocha tests properly 2016-02-01 00:24:08 +01:00
2fbcb58078 2.0.0 2016-01-31 22:25:36 +01:00
362f8d5388 major update 2016-01-31 22:24:57 +01:00
8fb4a60fb3 now includes mocha 2016-01-30 05:29:54 +01:00
7c6b5afd5f restructure 2016-01-30 04:57:24 +01:00
f83eb035c2 1.0.12 2016-01-25 21:20:28 +01:00
359e844c69 update plugins 2016-01-25 21:20:17 +01:00
6b40cfd954 1.0.11 2016-01-25 20:52:42 +01:00
8f13dbef9f fix issue with CI detection 2016-01-25 20:52:29 +01:00
9ff2453d7b 1.0.10 2016-01-25 20:25:10 +01:00
e40a82e8c9 improve info 2016-01-25 20:24:59 +01:00
cac50f7099 1.0.9 2016-01-18 19:12:21 +01:00
ef64874411 improve logging 2016-01-18 19:11:42 +01:00
44 changed files with 2781 additions and 75 deletions

3
.gitignore vendored
View File

@ -1,6 +1,7 @@
.idea/ .idea/
.c9/ .c9/
node_modules/ node_modules/
test/node_modules test/**/node_modules/
test/**/typings/
ts/*.js ts/*.js
ts/*.js.map ts/*.js.map

View File

@ -1,6 +1,6 @@
.idea/ .idea/
support support
compile compile
test test/
examples examples
.gitignore .gitignore

View File

@ -37,8 +37,23 @@ the TypeScript Compiler will use the declaration file to resolve typings.
### Custom behaviour ### Custom behaviour
We are currently building support for custom behaviour with a super simple config file. NPMTS looks for an npmts.json at the root of your package.
Check back soon.
```json
{
"mode":"custom",
"ts":{
"./customdir/custom.ts":"./customcompiled.js"
},
"typings":[
"./customdir"
]
}
```
* **mode** can be "default" or "custom"
* **ts** You can list as many TypeScript files as you like. The key represents the source TypeScript file, the value the output file.
* **typings** is an array of all direcories that have a typings.json present. Uses the new typings tool from npm.
## Readme for Devs ## Readme for Devs
There is a [README-dev.md](README-dev.md) in the repo. There is a [README-dev.md](README-dev.md) in the repo.

View File

@ -11,7 +11,7 @@ var plugins = {
}; };
plugins.beautylog.log('now compiling the mojo.io gulp tasks'); 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 tsResult = plugins.gulp.src('../ts/index.ts')

34
index.d.ts vendored
View File

@ -1,32 +1,58 @@
/// <reference path="../ts/typings/tsd.d.ts" /> /// <reference path="../ts/typings/main.d.ts" />
declare module NpmtsPlugins { declare module NpmtsPlugins {
var init: () => { var init: () => {
beautylog: any; beautylog: any;
fs: any;
gulp: any; gulp: any;
g: { g: {
typescript: any;
insert: any; insert: any;
sequence: any;
typescript: any;
}; };
mergeStream: any; mergeStream: any;
mocha: any;
path: any; path: any;
q: any;
smartcli: any; smartcli: any;
smartfile: any;
typings: any;
}; };
} }
declare module NpmtsPaths { declare module NpmtsPaths {
var init: () => any; var init: () => any;
} }
declare module NpmtsOptions {
var config: any;
var run: () => any;
}
declare module NpmtsCustom {
var run: () => any;
}
declare module NpmtsDefault { declare module NpmtsDefault {
var init: () => void; var run: () => any;
}
declare module NpmtsTests {
var run: () => any;
}
declare module NpmtsPromisechain {
var init: () => any;
} }
declare var plugins: { declare var plugins: {
beautylog: any; beautylog: any;
fs: any;
gulp: any; gulp: any;
g: { g: {
typescript: any;
insert: any; insert: any;
sequence: any;
typescript: any;
}; };
mergeStream: any; mergeStream: any;
mocha: any;
path: any; path: any;
q: any;
smartcli: any; smartcli: any;
smartfile: any;
typings: any;
}; };
declare var paths: any; declare var paths: any;
declare var promisechain: any;

181
index.js
View File

@ -6,14 +6,20 @@ var NpmtsPlugins;
NpmtsPlugins.init = function () { NpmtsPlugins.init = function () {
var plugins = { var plugins = {
beautylog: require("beautylog"), beautylog: require("beautylog"),
fs: require("fs-extra"),
gulp: require("gulp"), gulp: require("gulp"),
g: { g: {
typescript: require("gulp-typescript"), insert: require("gulp-insert"),
insert: require("gulp-insert") sequence: require("gulp-sequence"),
typescript: require("gulp-typescript")
}, },
mergeStream: require("merge2"), mergeStream: require("merge2"),
mocha: require("mocha"),
path: require("path"), path: require("path"),
smartcli: require("smartcli") q: require("q"),
smartcli: require("smartcli"),
smartfile: require("smartfile"),
typings: require("typings")
}; };
return plugins; return plugins;
}; };
@ -25,20 +31,120 @@ var NpmtsPaths;
NpmtsPaths.init = function () { NpmtsPaths.init = function () {
var paths = {}; var paths = {};
paths.cwd = plugins.smartcli.get.cwd().path; 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.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/");
return paths; return paths;
}; };
})(NpmtsPaths || (NpmtsPaths = {})); })(NpmtsPaths || (NpmtsPaths = {}));
/// <reference path="./index.ts" /> /// <reference path="./index.ts" />
var NpmtsOptions;
(function (NpmtsOptions) {
NpmtsOptions.config = {};
NpmtsOptions.run = function () {
var done = plugins.q.defer();
var configPath = plugins.path.join(paths.cwd, "npmts.json");
if (plugins.smartfile.checks.fileExistsSync(configPath)) {
plugins.beautylog.info("npmts.json".blue + " config file found!");
NpmtsOptions.config = plugins.smartfile.readFileToObject(configPath);
switch (NpmtsOptions.config.mode) {
case "default":
plugins.beautylog.log("mode is " + NpmtsOptions.config.mode.yellow);
done.resolve();
break;
case "custom":
plugins.beautylog.log("mode is " + NpmtsOptions.config.mode.yellow);
done.resolve();
break;
default:
plugins.beautylog.error("mode " + NpmtsOptions.config.mode.yellow + " not recognised!".red);
}
;
}
else {
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
NpmtsOptions.config.mode = "default";
done.resolve();
}
;
return done.promise;
};
})(NpmtsOptions || (NpmtsOptions = {}));
/// <reference path="./index.ts" />
var NpmtsCustom;
(function (NpmtsCustom) {
NpmtsCustom.run = function () {
var done = plugins.q.defer();
var config = NpmtsOptions.config;
if (config.mode === "custom") {
plugins.beautylog.log("now running custom tasks");
var moduleStream = plugins.mergeStream({ end: false });
/* -------------------------------------------------
* ----------- first install typings ---------------
* ----------------------------------------------- */
var typingsDone = plugins.q.defer();
var checkTypingsDone = function (indexArg, compareArray) {
if ((indexArg + 1) == compareArray.length) {
plugins.beautylog.success("custom typings installed successfully");
typingsDone.resolve();
}
};
for (var key in config.typings) {
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[key].blue);
plugins.typings.install({ production: false, cwd: plugins.path.join(paths.cwd, config.typings[key]) })
.then(function () {
checkTypingsDone(key, config.typings);
});
}
/* -------------------------------------------------
* ----------- second compile TS -------------------
* ----------------------------------------------- */
typingsDone.promise.then(function () {
for (var key in config.ts) {
plugins.beautylog.log("now compiling" + key.blue);
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd, key))
.pipe(plugins.g.typescript({
out: plugins.path.basename(config.ts[key]),
declaration: true
}));
var stream = plugins.mergeStream([
tsStream.dts.pipe(plugins.gulp.dest(paths.cwd)),
tsStream.js
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest(plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]))))
]);
moduleStream.add(stream);
}
moduleStream.on("queueDrain", function () {
plugins.beautylog.success("custom TypeScript installed successfully");
moduleStream.on("finish", function () {
done.resolve();
});
moduleStream.end();
});
});
}
return done.promise;
};
})(NpmtsCustom || (NpmtsCustom = {}));
/// <reference path="./index.ts" /> /// <reference path="./index.ts" />
var NpmtsDefault; var NpmtsDefault;
(function (NpmtsDefault) { (function (NpmtsDefault) {
NpmtsDefault.init = function () { NpmtsDefault.run = function () {
plugins.gulp.task("indexTS", function () { var done = plugins.q.defer();
plugins.gulp.task("defaultTypings", function (cb) {
plugins.beautylog.log("now installing default typings");
plugins.typings.install({ production: false, cwd: paths.tsDir })
.then(function () {
cb();
});
});
plugins.gulp.task("defaultIndexTS", function () {
plugins.beautylog.log("now compiling" + " ts/index.ts".blue);
var tsResult = plugins.gulp.src(paths.indexTS) var tsResult = plugins.gulp.src(paths.indexTS)
.pipe(plugins.g.typescript({ .pipe(plugins.g.typescript({
out: "index.js", out: "./index.js",
declaration: true declaration: true
})); }));
return plugins.mergeStream([ return plugins.mergeStream([
@ -48,25 +154,72 @@ var NpmtsDefault;
.pipe(plugins.gulp.dest(paths.cwd)) .pipe(plugins.gulp.dest(paths.cwd))
]); ]);
}); });
plugins.gulp.task("testTS", function () { plugins.gulp.task("defaultTestTS", function () {
plugins.gulp.src(paths.testTS) plugins.beautylog.log("now compiling" + " ts/test.ts".blue);
var stream = plugins.gulp.src(paths.testTS)
.pipe(plugins.g.typescript({ .pipe(plugins.g.typescript({
out: "test.js" out: "test.js"
})) }))
.pipe(plugins.gulp.dest(paths.cwd)); .pipe(plugins.gulp.dest(paths.testDir));
return stream;
}); });
plugins.gulp.task("default", ["indexTS", "testTS"], function () { plugins.gulp.task("defaultCleanup", function (cb) {
plugins.beautylog.success("TypeScript for this module was compiled successfully."); plugins.beautylog.success("default TypeScript for this module compiled successfully.");
done.resolve();
cb();
});
plugins.gulp.task("default", function (cb) {
if (NpmtsOptions.config.mode == "default") {
plugins.g.sequence("defaultTypings", "defaultIndexTS", "defaultTestTS", "defaultCleanup", cb);
}
else {
cb();
done.resolve();
}
}); });
plugins.gulp.start.apply(plugins.gulp, ['default']); plugins.gulp.start.apply(plugins.gulp, ['default']);
return done.promise;
}; };
})(NpmtsDefault || (NpmtsDefault = {})); })(NpmtsDefault || (NpmtsDefault = {}));
/// <reference path="./typings/tsd.d.ts" /> /// <reference path="./index.ts" />
var NpmtsTests;
(function (NpmtsTests) {
NpmtsTests.run = function () {
var done = plugins.q.defer();
plugins.fs.ensureDirSync(paths.testDir); //make sure that mocha has a directory to look for tests
plugins.beautylog.info("Now running mocha tests");
var mocha = new plugins.mocha(); // Instantiate a Mocha instance.
mocha.addFile(plugins.path.join(paths.testDir, "test.js"));
mocha.run(function (failures) {
process.on('exit', function () {
process.exit(failures);
});
});
return done.promise;
};
})(NpmtsTests || (NpmtsTests = {}));
/// <reference path="./index.ts" />
var NpmtsPromisechain;
(function (NpmtsPromisechain) {
NpmtsPromisechain.init = function () {
var promisechain;
NpmtsOptions.run()
.then(NpmtsDefault.run)
.then(NpmtsCustom.run)
.then(NpmtsTests.run);
return promisechain;
};
})(NpmtsPromisechain || (NpmtsPromisechain = {}));
/// <reference path="./typings/main.d.ts" />
/// <reference path="./npmts.plugins.ts" /> /// <reference path="./npmts.plugins.ts" />
/// <reference path="./npmts.cli.ts" /> /// <reference path="./npmts.cli.ts" />
/// <reference path="./npmts.paths.ts" /> /// <reference path="./npmts.paths.ts" />
/// <reference path="./npmts.options.ts" />
/// <reference path="./npmts.custom.ts" /> /// <reference path="./npmts.custom.ts" />
/// <reference path="./npmts.default.ts" /> /// <reference path="./npmts.default.ts" />
/// <reference path="./npmts.tests.ts" />
/// <reference path="./npmts.promisechain.ts" />
console.log("**** starting NPMTS ****");
var plugins = NpmtsPlugins.init(); var plugins = NpmtsPlugins.init();
var paths = NpmtsPaths.init(); var paths = NpmtsPaths.init();
NpmtsDefault.init(); var promisechain = NpmtsPromisechain.init();

View File

@ -1,6 +1,6 @@
{ {
"name": "npmts", "name": "npmts",
"version": "1.0.8", "version": "2.1.0",
"description": "write npm modules with TypeScript", "description": "write npm modules with TypeScript",
"main": "index.js", "main": "index.js",
"typings": "./index.d.ts", "typings": "./index.d.ts",
@ -9,8 +9,8 @@
}, },
"scripts": { "scripts": {
"test": "(cd compile && node compile.js)", "test": "(cd compile && node compile.js)",
"release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)", "testm": "(npm test) && (cd test/assets && node ../../index.js)",
"testm": "(cd test/ && node ../index.js)" "release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -27,13 +27,18 @@
}, },
"homepage": "https://github.com/pushrocks/npmts#readme", "homepage": "https://github.com/pushrocks/npmts#readme",
"dependencies": { "dependencies": {
"beautylog": "2.0.2", "beautylog": "2.0.7",
"fs-extra": "^0.26.5",
"gulp": "3.9.0", "gulp": "3.9.0",
"gulp-insert": "0.5.0", "gulp-insert": "0.5.0",
"gulp-sequence": "^0.4.4", "gulp-sequence": "^0.4.4",
"gulp-tsd": "^0.1.0",
"gulp-typescript": "2.10.0", "gulp-typescript": "2.10.0",
"merge2": "0.3.6", "gulp-typings": "0.0.0",
"smartcli": "0.0.11" "merge2": "1.0.1",
"mocha": "^2.4.5",
"q": "^1.4.1",
"smartcli": "0.0.11",
"smartfile": "0.0.11",
"typings": "^0.6.6"
} }
} }

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

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

View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
var hello = "hello";

View File

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

View File

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

View File

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

View File

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

0
test/assets/index.d.ts vendored Normal file
View File

5
test/assets/index.js Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env node
(function () {
console.log("test");
}());

9
test/assets/npmts.json Normal file
View File

@ -0,0 +1,9 @@
{
"mode":"custom",
"ts":{
"./customdir/custom.ts":"./customcompiled.js"
},
"typings":[
"./customdir"
]
}

View File

@ -9,6 +9,5 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"npmts": "*"
} }
} }

1
test/assets/test/test.js Normal file
View File

@ -0,0 +1 @@
console.log("**** starting test ****");

2
test/assets/ts/test.js Normal file
View File

@ -0,0 +1,2 @@
console.log("**** starting test ****");
//# sourceMappingURL=test.js.map

View File

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

1
test/assets/ts/test.ts Normal file
View File

@ -0,0 +1 @@
console.log("**** starting test ****");

View File

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

View File

@ -1,10 +1,13 @@
/// <reference path="./typings/tsd.d.ts" /> /// <reference path="./typings/main.d.ts" />
/// <reference path="./npmts.plugins.ts" /> /// <reference path="./npmts.plugins.ts" />
/// <reference path="./npmts.cli.ts" /> /// <reference path="./npmts.cli.ts" />
/// <reference path="./npmts.paths.ts" /> /// <reference path="./npmts.paths.ts" />
/// <reference path="./npmts.options.ts" />
/// <reference path="./npmts.custom.ts" /> /// <reference path="./npmts.custom.ts" />
/// <reference path="./npmts.default.ts" /> /// <reference path="./npmts.default.ts" />
/// <reference path="./npmts.tests.ts" />
/// <reference path="./npmts.promisechain.ts" />
console.log("**** starting NPMTS ****")
var plugins = NpmtsPlugins.init(); var plugins = NpmtsPlugins.init();
var paths = NpmtsPaths.init(); var paths = NpmtsPaths.init();
NpmtsDefault.init(); var promisechain = NpmtsPromisechain.init();

View File

@ -1 +1,60 @@
/// <reference path="./index.ts" /> /// <reference path="./index.ts" />
module NpmtsCustom {
export var run = function(){
var done = plugins.q.defer();
var config = NpmtsOptions.config;
if(config.mode === "custom"){
plugins.beautylog.log("now running custom tasks");
var moduleStream = plugins.mergeStream({end: false});
/* -------------------------------------------------
* ----------- first install typings ---------------
* ----------------------------------------------- */
var typingsDone = plugins.q.defer();
var checkTypingsDone = function(indexArg:number,compareArray){
if((indexArg + 1) == compareArray.length){
plugins.beautylog.success("custom typings installed successfully");
typingsDone.resolve();
}
};
for (var key in config.typings) {
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[key].blue);
plugins.typings.install({production: false, cwd: plugins.path.join(paths.cwd,config.typings[key])})
.then(function(){
checkTypingsDone(key,config.typings);
});
}
/* -------------------------------------------------
* ----------- second compile TS -------------------
* ----------------------------------------------- */
typingsDone.promise.then(function(){
for (var key in config.ts) {
plugins.beautylog.log("now compiling" + key.blue);
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd,key))
.pipe(plugins.g.typescript({
out: plugins.path.basename(config.ts[key]),
declaration: true
}));
var stream = plugins.mergeStream([
tsStream.dts.pipe(plugins.gulp.dest(paths.cwd)),
tsStream.js
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest(
plugins.path.dirname(
plugins.path.join(paths.cwd,config.ts[key])
)
))
]);
moduleStream.add(stream);
}
moduleStream.on("queueDrain",function(){
plugins.beautylog.success("custom TypeScript installed successfully");
moduleStream.on("finish",function(){
done.resolve();
});
moduleStream.end();
});
});
}
return done.promise;
}
}

View File

@ -1,19 +1,20 @@
/// <reference path="./index.ts" /> /// <reference path="./index.ts" />
module NpmtsDefault { module NpmtsDefault {
export var init = function() { export var run = function() {
plugins.gulp.task("defaultTsd",function(cb){ var done = plugins.q.defer();
plugins.g.tsd({ plugins.gulp.task("defaultTypings",function(cb){
command: 'reinstall', plugins.beautylog.log("now installing default typings");
config: paths.tsd plugins.typings.install({production: false, cwd: paths.tsDir})
}, cb); .then(function(){
cb();
});
}); });
plugins.gulp.task("defaultIndexTS", function(){ plugins.gulp.task("defaultIndexTS", function(){
plugins.beautylog.log("now compiling" + " ts/index.ts".blue);
var tsResult = plugins.gulp.src(paths.indexTS) var tsResult = plugins.gulp.src(paths.indexTS)
.pipe(plugins.g.typescript({ .pipe(plugins.g.typescript({
out:"index.js", out:"./index.js",
declaration:true declaration:true
})); }));
@ -26,18 +27,32 @@ module NpmtsDefault {
}); });
plugins.gulp.task("defaultTestTS", function(){ plugins.gulp.task("defaultTestTS", function(){
plugins.gulp.src(paths.testTS) plugins.beautylog.log("now compiling" + " ts/test.ts".blue);
var stream = plugins.gulp.src(paths.testTS)
.pipe(plugins.g.typescript({ .pipe(plugins.g.typescript({
out: "test.js" out: "test.js"
})) }))
.pipe(plugins.gulp.dest(paths.cwd)) .pipe(plugins.gulp.dest(paths.testDir));
return stream;
});
plugins.gulp.task("defaultCleanup",function(cb){
plugins.beautylog.success("default TypeScript for this module compiled successfully.");
done.resolve();
cb();
}); });
plugins.gulp.task("default",function(cb){ plugins.gulp.task("default",function(cb){
plugins.g.sequence("defaultTsd","defaultIndexTS","defaultTestTS"); if(NpmtsOptions.config.mode == "default"){
plugins.beautylog.success("TypeScript for this module was compiled successfully."); plugins.g.sequence("defaultTypings","defaultIndexTS","defaultTestTS","defaultCleanup",cb);
} else {
cb();
done.resolve();
}
}); });
plugins.gulp.start.apply(plugins.gulp, ['default']); plugins.gulp.start.apply(plugins.gulp, ['default']);
return done.promise;
} }
} }

29
ts/npmts.options.ts Normal file
View File

@ -0,0 +1,29 @@
/// <reference path="./index.ts" />
module NpmtsOptions {
export var config:any = {};
export var run = function(){
var done = plugins.q.defer();
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":
plugins.beautylog.log("mode is " + config.mode.yellow);
done.resolve();
break;
case "custom":
plugins.beautylog.log("mode is " + config.mode.yellow);
done.resolve();
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();
};
return done.promise;
}
}

View File

@ -3,8 +3,10 @@ module NpmtsPaths {
export var init = function() { 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.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/");
return paths; return paths;
} }
} }

View File

@ -3,17 +3,21 @@ module NpmtsPlugins {
export var init = function() { export var init = function() {
var plugins = { var plugins = {
beautylog: require("beautylog"), beautylog: require("beautylog"),
fs: require("fs-extra"),
gulp: require("gulp"), gulp: require("gulp"),
g: { g: {
insert: require("gulp-insert"), insert: require("gulp-insert"),
sequence: require("gulp-sequence"), sequence: require("gulp-sequence"),
tsd: require("gulp-tsd"),
typescript: require("gulp-typescript") typescript: require("gulp-typescript")
}, },
mergeStream: require("merge2"), mergeStream: require("merge2"),
mocha: require("mocha"),
path: require("path"), path: require("path"),
smartcli: require("smartcli") q:require("q"),
smartcli: require("smartcli"),
smartfile: require("smartfile"),
typings: require("typings")
}; };
return plugins; return plugins;
} }

11
ts/npmts.promisechain.ts Normal file
View File

@ -0,0 +1,11 @@
/// <reference path="./index.ts" />
module NpmtsPromisechain {
export var init = function(){
var promisechain;
NpmtsOptions.run()
.then(NpmtsDefault.run)
.then(NpmtsCustom.run)
.then(NpmtsTests.run);
return promisechain;
}
}

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

@ -0,0 +1,19 @@
/// <reference path="./index.ts" />
module NpmtsTests {
export var run = function() {
var done = plugins.q.defer();
plugins.fs.ensureDirSync(paths.testDir); //make sure that mocha has a directory to look for tests
plugins.beautylog.info("Now running mocha tests");
var mocha = new plugins.mocha(); // Instantiate a Mocha instance.
mocha.addFile(
plugins.path.join(paths.testDir, "test.js")
);
mocha.run(function(failures){
process.on('exit', function () {
process.exit(failures);
});
});
return done.promise;
}
}

View File

@ -1,18 +0,0 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"node/node.d.ts": {
"commit": "78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
},
"colors/colors.d.ts": {
"commit": "09e37435ffb2c56a6f908081194a74756f24f99d"
},
"vinyl/vinyl.d.ts": {
"commit": "78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
}
}
}

7
ts/typings.json Normal file
View File

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

3
ts/typings/browser.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
/// <reference path="browser/ambient/colors/colors.d.ts" />
/// <reference path="browser/ambient/node/node.d.ts" />
/// <reference path="browser/ambient/vinyl/vinyl.d.ts" />

View File

@ -1,3 +1,5 @@
// Compiled using typings@0.6.3
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/09e37435ffb2c56a6f908081194a74756f24f99d/colors/colors.d.ts
// Type definitions for Colors.js 0.6.0-1 // Type definitions for Colors.js 0.6.0-1
// Project: https://github.com/Marak/colors.js // Project: https://github.com/Marak/colors.js
// Definitions by: Bart van der Schoor <https://github.com/Bartvds> // Definitions by: Bart van der Schoor <https://github.com/Bartvds>
@ -120,4 +122,4 @@ interface String {
america: string; america: string;
trap: string; trap: string;
random: string; random: string;
} }

View File

@ -1,3 +1,5 @@
// Compiled using typings@0.6.3
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/78d36dd49b6b55b9fdfe61776a12bf05c8b07777/node/node.d.ts
// Type definitions for Node.js v4.x // Type definitions for Node.js v4.x
// Project: http://nodejs.org/ // Project: http://nodejs.org/
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>, DefinitelyTyped <https://github.com/borisyankov/DefinitelyTyped> // Definitions by: Microsoft TypeScript <http://typescriptlang.org>, DefinitelyTyped <https://github.com/borisyankov/DefinitelyTyped>
@ -2087,4 +2089,4 @@ declare module "constants" {
export var W_OK: number; export var W_OK: number;
export var X_OK: number; export var X_OK: number;
export var UV_UDP_REUSEADDR: number; export var UV_UDP_REUSEADDR: number;
} }

View File

@ -1,9 +1,10 @@
// Compiled using typings@0.6.3
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/78d36dd49b6b55b9fdfe61776a12bf05c8b07777/vinyl/vinyl.d.ts
// Type definitions for vinyl 0.4.3 // Type definitions for vinyl 0.4.3
// Project: https://github.com/wearefractal/vinyl // Project: https://github.com/wearefractal/vinyl
// Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao> // Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao>
// Definitions: https://github.com/borisyankov/DefinitelyTyped // Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module 'vinyl' { declare module 'vinyl' {
@ -106,4 +107,4 @@ declare module 'vinyl' {
export = File; export = File;
} }

3
ts/typings/main.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
/// <reference path="main/ambient/colors/colors.d.ts" />
/// <reference path="main/ambient/node/node.d.ts" />
/// <reference path="main/ambient/vinyl/vinyl.d.ts" />

View File

@ -0,0 +1,125 @@
// Compiled using typings@0.6.3
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/09e37435ffb2c56a6f908081194a74756f24f99d/colors/colors.d.ts
// Type definitions for Colors.js 0.6.0-1
// Project: https://github.com/Marak/colors.js
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "colors" {
interface Color {
(text: string): string;
black: Color;
red: Color;
green: Color;
yellow: Color;
blue: Color;
magenta: Color;
cyan: Color;
white: Color;
gray: Color;
grey: Color;
bgBlack: Color;
bgRed: Color;
bgGreen: Color;
bgYellow: Color;
bgBlue: Color;
bgMagenta: Color;
bgCyan: Color;
bgWhite: Color;
reset: Color;
bold: Color;
dim: Color;
italic: Color;
underline: Color;
inverse: Color;
hidden: Color;
strikethrough: Color;
rainbow: Color;
zebra: Color;
america: Color;
trap: Color;
random: Color;
}
module e {
export function setTheme(theme:any): void;
export var black: Color;
export var red: Color;
export var green: Color;
export var yellow: Color;
export var blue: Color;
export var magenta: Color;
export var cyan: Color;
export var white: Color;
export var gray: Color;
export var grey: Color;
export var bgBlack: Color;
export var bgRed: Color;
export var bgGreen: Color;
export var bgYellow: Color;
export var bgBlue: Color;
export var bgMagenta: Color;
export var bgCyan: Color;
export var bgWhite: Color;
export var reset: Color;
export var bold: Color;
export var dim: Color;
export var italic: Color;
export var underline: Color;
export var inverse: Color;
export var hidden: Color;
export var strikethrough: Color;
export var rainbow: Color;
export var zebra: Color;
export var america: Color;
export var trap: Color;
export var random: Color;
}
export = e;
}
interface String {
black: string;
red: string;
green: string;
yellow: string;
blue: string;
magenta: string;
cyan: string;
white: string;
gray: string;
grey: string;
bgBlack: string;
bgRed: string;
bgGreen: string;
bgYellow: string;
bgBlue: string;
bgMagenta: string;
bgCyan: string;
bgWhite: string;
reset: string;
bold: string;
dim: string;
italic: string;
underline: string;
inverse: string;
hidden: string;
strikethrough: string;
rainbow: string;
zebra: string;
america: string;
trap: string;
random: string;
}

2092
ts/typings/main/ambient/node/node.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

110
ts/typings/main/ambient/vinyl/vinyl.d.ts vendored Normal file
View File

@ -0,0 +1,110 @@
// Compiled using typings@0.6.3
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/78d36dd49b6b55b9fdfe61776a12bf05c8b07777/vinyl/vinyl.d.ts
// Type definitions for vinyl 0.4.3
// Project: https://github.com/wearefractal/vinyl
// Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'vinyl' {
import fs = require('fs');
/**
* A virtual file format.
*/
class File {
constructor(options?: {
/**
* Default: process.cwd()
*/
cwd?: string;
/**
* Used for relative pathing. Typically where a glob starts.
*/
base?: string;
/**
* Full path to the file.
*/
path?: string;
/**
* Path history. Has no effect if options.path is passed.
*/
history?: string[];
/**
* The result of an fs.stat call. See fs.Stats for more information.
*/
stat?: fs.Stats;
/**
* File contents.
* Type: Buffer, Stream, or null
*/
contents?: Buffer | NodeJS.ReadWriteStream;
});
/**
* Default: process.cwd()
*/
public cwd: string;
/**
* Used for relative pathing. Typically where a glob starts.
*/
public base: string;
/**
* Full path to the file.
*/
public path: string;
public stat: fs.Stats;
/**
* Type: Buffer|Stream|null (Default: null)
*/
public contents: Buffer | NodeJS.ReadableStream;
/**
* Returns path.relative for the file base and file path.
* Example:
* var file = new File({
* cwd: "/",
* base: "/test/",
* path: "/test/file.js"
* });
* console.log(file.relative); // file.js
*/
public relative: string;
public isBuffer(): boolean;
public isStream(): boolean;
public isNull(): boolean;
public isDirectory(): boolean;
/**
* Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.
*/
public clone(opts?: { contents?: boolean }): File;
/**
* If file.contents is a Buffer, it will write it to the stream.
* If file.contents is a Stream, it will pipe it to the stream.
* If file.contents is null, it will do nothing.
*/
public pipe<T extends NodeJS.ReadWriteStream>(
stream: T,
opts?: {
/**
* If false, the destination stream will not be ended (same as node core).
*/
end?: boolean;
}
): T;
/**
* Returns a pretty String interpretation of the File. Useful for console.log.
*/
public inspect(): string;
}
export = File;
}

3
ts/typings/tsd.d.ts vendored
View File

@ -1,3 +0,0 @@
/// <reference path="node/node.d.ts" />
/// <reference path="colors/colors.d.ts" />
/// <reference path="vinyl/vinyl.d.ts" />