Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
3f0b2b1599 | |||
d477e492eb | |||
f39cb03fc2 | |||
f42744b927 | |||
038994e9e5 | |||
7a26721420 | |||
0dc307f082 | |||
4b2c0fe461 | |||
50fd5e83ad | |||
3e55a666b2 | |||
5d8ce3f227 | |||
de4bbaed9f | |||
7d18e92ff1 | |||
634763c03f | |||
3352165436 | |||
6c57a4703f |
19
README.md
19
README.md
@ -37,8 +37,23 @@ the TypeScript Compiler will use the declaration file to resolve typings.
|
||||
|
||||
|
||||
### Custom behaviour
|
||||
We are currently building support for custom behaviour with a super simple config file.
|
||||
Check back soon.
|
||||
NPMTS looks for an npmts.json at the root of your package.
|
||||
|
||||
```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
|
||||
There is a [README-dev.md](README-dev.md) in the repo.
|
||||
|
7
index.d.ts
vendored
7
index.d.ts
vendored
@ -9,11 +9,13 @@ declare module NpmtsPlugins {
|
||||
sequence: any;
|
||||
typescript: any;
|
||||
};
|
||||
mathjs: any;
|
||||
mergeStream: any;
|
||||
mocha: any;
|
||||
path: any;
|
||||
q: any;
|
||||
smartcli: any;
|
||||
smartfile: any;
|
||||
typings: any;
|
||||
};
|
||||
}
|
||||
@ -21,9 +23,10 @@ declare module NpmtsPaths {
|
||||
var init: () => any;
|
||||
}
|
||||
declare module NpmtsOptions {
|
||||
var config: any;
|
||||
var run: () => any;
|
||||
}
|
||||
declare module NpmtsTypings {
|
||||
declare module NpmtsCustom {
|
||||
var run: () => any;
|
||||
}
|
||||
declare module NpmtsDefault {
|
||||
@ -44,11 +47,13 @@ declare var plugins: {
|
||||
sequence: any;
|
||||
typescript: any;
|
||||
};
|
||||
mathjs: any;
|
||||
mergeStream: any;
|
||||
mocha: any;
|
||||
path: any;
|
||||
q: any;
|
||||
smartcli: any;
|
||||
smartfile: any;
|
||||
typings: any;
|
||||
};
|
||||
declare var paths: any;
|
||||
|
154
index.js
154
index.js
@ -13,11 +13,13 @@ var NpmtsPlugins;
|
||||
sequence: require("gulp-sequence"),
|
||||
typescript: require("gulp-typescript")
|
||||
},
|
||||
mathjs: require("mathjs"),
|
||||
mergeStream: require("merge2"),
|
||||
mocha: require("mocha"),
|
||||
path: require("path"),
|
||||
q: require("q"),
|
||||
smartcli: require("smartcli"),
|
||||
smartfile: require("smartfile"),
|
||||
typings: require("typings")
|
||||
};
|
||||
return plugins;
|
||||
@ -40,36 +42,147 @@ var NpmtsPaths;
|
||||
/// <reference path="./index.ts" />
|
||||
var NpmtsOptions;
|
||||
(function (NpmtsOptions) {
|
||||
NpmtsOptions.config = {};
|
||||
NpmtsOptions.run = function () {
|
||||
var done = plugins.q.defer();
|
||||
done.resolve(); //TODO: check for options
|
||||
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 NpmtsTypings;
|
||||
(function (NpmtsTypings) {
|
||||
NpmtsTypings.run = function () {
|
||||
var NpmtsCustom;
|
||||
(function (NpmtsCustom) {
|
||||
NpmtsCustom.run = function () {
|
||||
var done = plugins.q.defer();
|
||||
plugins.beautylog.log("now installing typings");
|
||||
plugins.typings.install({ production: false, cwd: paths.tsDir })
|
||||
.then(function () {
|
||||
done.resolve();
|
||||
});
|
||||
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 typingsCounter = 0;
|
||||
var typingsCounterAdvance = function () {
|
||||
typingsCounter++;
|
||||
if (typeof config.typings[typingsCounter] != "undefined") {
|
||||
installTypings();
|
||||
}
|
||||
else {
|
||||
plugins.beautylog.success("custom typings installed successfully");
|
||||
typingsDone.resolve();
|
||||
}
|
||||
};
|
||||
var installTypings = function () {
|
||||
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
|
||||
plugins.typings.install({ production: false, cwd: plugins.path.join(paths.cwd, config.typings[typingsCounter]) })
|
||||
.then(function () {
|
||||
typingsCounterAdvance();
|
||||
}, function () {
|
||||
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
|
||||
typingsCounterAdvance();
|
||||
});
|
||||
};
|
||||
installTypings();
|
||||
/* -------------------------------------------------
|
||||
* ----------- second compile TS -------------------
|
||||
* ----------------------------------------------- */
|
||||
typingsDone.promise.then(function () {
|
||||
for (var key in config.ts) {
|
||||
plugins.beautylog.log("now compiling" + key.blue);
|
||||
var outputPathIsDir;
|
||||
try {
|
||||
if (plugins.fs.statSync(plugins.path.join(paths.cwd, config.ts[key])).isDirectory()) {
|
||||
outputPathIsDir = true;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
outputPathIsDir = false;
|
||||
}
|
||||
//do some evaluation of the environment
|
||||
var outputNameSpecified = (!outputPathIsDir
|
||||
&& (plugins.path.extname(config.ts[key]) == ".js"));
|
||||
var outputName = (function () {
|
||||
if (outputNameSpecified) {
|
||||
return plugins.path.basename(config.ts[key]);
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
})();
|
||||
var outputDir = (function () {
|
||||
if (outputNameSpecified) {
|
||||
return plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]));
|
||||
}
|
||||
else {
|
||||
return plugins.path.join(paths.cwd, config.ts[key]);
|
||||
}
|
||||
})();
|
||||
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd, key))
|
||||
.pipe(plugins.g.typescript({
|
||||
out: outputName,
|
||||
declaration: true
|
||||
}));
|
||||
var stream = plugins.mergeStream([
|
||||
tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
|
||||
tsStream.js
|
||||
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
|
||||
.pipe(plugins.gulp.dest(outputDir))
|
||||
]);
|
||||
moduleStream.add(stream);
|
||||
}
|
||||
moduleStream.on("queueDrain", function () {
|
||||
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||
moduleStream.on("finish", function () {
|
||||
done.resolve();
|
||||
});
|
||||
moduleStream.end();
|
||||
});
|
||||
});
|
||||
}
|
||||
return done.promise;
|
||||
};
|
||||
})(NpmtsTypings || (NpmtsTypings = {}));
|
||||
/// <reference path="./index.ts" />
|
||||
})(NpmtsCustom || (NpmtsCustom = {}));
|
||||
/// <reference path="./index.ts" />
|
||||
var NpmtsDefault;
|
||||
(function (NpmtsDefault) {
|
||||
NpmtsDefault.run = 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)
|
||||
.pipe(plugins.g.typescript({
|
||||
out: "index.js",
|
||||
out: "./index.js",
|
||||
declaration: true
|
||||
}));
|
||||
return plugins.mergeStream([
|
||||
@ -81,19 +194,26 @@ var NpmtsDefault;
|
||||
});
|
||||
plugins.gulp.task("defaultTestTS", function () {
|
||||
plugins.beautylog.log("now compiling" + " ts/test.ts".blue);
|
||||
plugins.gulp.src(paths.testTS)
|
||||
var stream = plugins.gulp.src(paths.testTS)
|
||||
.pipe(plugins.g.typescript({
|
||||
out: "test.js"
|
||||
}))
|
||||
.pipe(plugins.gulp.dest(paths.testDir));
|
||||
return stream;
|
||||
});
|
||||
plugins.gulp.task("defaultCleanup", function (cb) {
|
||||
plugins.beautylog.success("TypeScript for this module compiled successfully.");
|
||||
plugins.beautylog.success("default TypeScript for this module compiled successfully.");
|
||||
done.resolve();
|
||||
cb();
|
||||
});
|
||||
plugins.gulp.task("default", function (cb) {
|
||||
plugins.g.sequence("defaultIndexTS", "defaultTestTS", "defaultCleanup", 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']);
|
||||
return done.promise;
|
||||
@ -108,7 +228,6 @@ var NpmtsTests;
|
||||
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"));
|
||||
// Run the tests.
|
||||
mocha.run(function (failures) {
|
||||
process.on('exit', function () {
|
||||
process.exit(failures);
|
||||
@ -123,8 +242,8 @@ var NpmtsPromisechain;
|
||||
NpmtsPromisechain.init = function () {
|
||||
var promisechain;
|
||||
NpmtsOptions.run()
|
||||
.then(NpmtsTypings.run)
|
||||
.then(NpmtsDefault.run)
|
||||
.then(NpmtsCustom.run)
|
||||
.then(NpmtsTests.run);
|
||||
return promisechain;
|
||||
};
|
||||
@ -134,7 +253,6 @@ var NpmtsPromisechain;
|
||||
/// <reference path="./npmts.cli.ts" />
|
||||
/// <reference path="./npmts.paths.ts" />
|
||||
/// <reference path="./npmts.options.ts" />
|
||||
/// <reference path="./npmts.typings.ts" />
|
||||
/// <reference path="./npmts.custom.ts" />
|
||||
/// <reference path="./npmts.default.ts" />
|
||||
/// <reference path="./npmts.tests.ts" />
|
||||
|
13
package.json
13
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "npmts",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.5",
|
||||
"description": "write npm modules with TypeScript",
|
||||
"main": "index.js",
|
||||
"typings": "./index.d.ts",
|
||||
@ -8,8 +8,7 @@
|
||||
"npmts": "./index.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "(cd compile && node compile.js)",
|
||||
"testm": "(npm test) && (cd test/assets && node ../../index.js)",
|
||||
"test": "(cd compile && node compile.js) && (cd test/assets && node ../../index.js)",
|
||||
"release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)"
|
||||
},
|
||||
"repository": {
|
||||
@ -27,17 +26,19 @@
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/npmts#readme",
|
||||
"dependencies": {
|
||||
"beautylog": "2.0.2",
|
||||
"beautylog": "2.0.7",
|
||||
"fs-extra": "^0.26.5",
|
||||
"gulp": "3.9.0",
|
||||
"gulp-insert": "0.5.0",
|
||||
"gulp-sequence": "^0.4.4",
|
||||
"gulp-typescript": "2.10.0",
|
||||
"gulp-typings": "0.0.0",
|
||||
"merge2": "0.3.6",
|
||||
"mathjs": "^2.7.0",
|
||||
"merge2": "1.0.1",
|
||||
"mocha": "^2.4.5",
|
||||
"q": "^1.4.1",
|
||||
"smartcli": "0.0.11",
|
||||
"typings": "^0.6.3"
|
||||
"smartfile": "0.0.11",
|
||||
"typings": "^0.6.6"
|
||||
}
|
||||
}
|
||||
|
1
test/assets/custom.d.ts
vendored
Normal file
1
test/assets/custom.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare var hello: string;
|
3
test/assets/custom.js
Normal file
3
test/assets/custom.js
Normal file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var hello = "hello";
|
2
test/assets/customdir/custom.js
Normal file
2
test/assets/customdir/custom.js
Normal file
@ -0,0 +1,2 @@
|
||||
var hello = "hello";
|
||||
//# sourceMappingURL=custom.js.map
|
1
test/assets/customdir/custom.js.map
Normal file
1
test/assets/customdir/custom.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"custom.js","sourceRoot":"","sources":["custom.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,OAAO,CAAC"}
|
1
test/assets/customdir/custom.ts
Normal file
1
test/assets/customdir/custom.ts
Normal file
@ -0,0 +1 @@
|
||||
var hello = "hello";
|
2
test/assets/customdir/tsfile1.js
Normal file
2
test/assets/customdir/tsfile1.js
Normal file
@ -0,0 +1,2 @@
|
||||
var something = "something";
|
||||
//# sourceMappingURL=tsfile1.js.map
|
1
test/assets/customdir/tsfile1.js.map
Normal file
1
test/assets/customdir/tsfile1.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"tsfile1.js","sourceRoot":"","sources":["tsfile1.ts"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,WAAW,CAAC"}
|
1
test/assets/customdir/tsfile1.ts
Normal file
1
test/assets/customdir/tsfile1.ts
Normal file
@ -0,0 +1 @@
|
||||
var something = "something";
|
7
test/assets/customdir/typings.json
Normal file
7
test/assets/customdir/typings.json
Normal 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"
|
||||
}
|
||||
}
|
12
test/assets/npmts.json
Normal file
12
test/assets/npmts.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"mode":"custom",
|
||||
"ts":{
|
||||
"./customdir/*.ts":"./"
|
||||
},
|
||||
"typings":[
|
||||
"./ts",
|
||||
"./subts1/",
|
||||
"./subts2/",
|
||||
"./customdir"
|
||||
]
|
||||
}
|
7
test/assets/subts1/typings.json
Normal file
7
test/assets/subts1/typings.json
Normal 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"
|
||||
}
|
||||
}
|
1
test/assets/tsfile1.d.ts
vendored
Normal file
1
test/assets/tsfile1.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare var something: string;
|
3
test/assets/tsfile1.js
Normal file
3
test/assets/tsfile1.js
Normal file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var something = "something";
|
@ -3,7 +3,6 @@
|
||||
/// <reference path="./npmts.cli.ts" />
|
||||
/// <reference path="./npmts.paths.ts" />
|
||||
/// <reference path="./npmts.options.ts" />
|
||||
/// <reference path="./npmts.typings.ts" />
|
||||
/// <reference path="./npmts.custom.ts" />
|
||||
/// <reference path="./npmts.default.ts" />
|
||||
/// <reference path="./npmts.tests.ts" />
|
||||
|
@ -1 +1,95 @@
|
||||
/// <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 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 tsStream = plugins.gulp.src(plugins.path.join(paths.cwd,key))
|
||||
.pipe(plugins.g.typescript({
|
||||
out: outputName,
|
||||
declaration: true
|
||||
}));
|
||||
var stream = plugins.mergeStream([
|
||||
tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
|
||||
tsStream.js
|
||||
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
|
||||
.pipe(plugins.gulp.dest(outputDir))
|
||||
]);
|
||||
moduleStream.add(stream);
|
||||
}
|
||||
moduleStream.on("queueDrain",function(){
|
||||
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||
moduleStream.on("finish",function(){
|
||||
done.resolve();
|
||||
});
|
||||
moduleStream.end();
|
||||
});
|
||||
});
|
||||
}
|
||||
return done.promise;
|
||||
}
|
||||
}
|
@ -3,13 +3,18 @@
|
||||
module NpmtsDefault {
|
||||
export var run = 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)
|
||||
.pipe(plugins.g.typescript({
|
||||
out:"index.js",
|
||||
out:"./index.js",
|
||||
declaration:true
|
||||
}));
|
||||
|
||||
@ -23,21 +28,28 @@ module NpmtsDefault {
|
||||
|
||||
plugins.gulp.task("defaultTestTS", function(){
|
||||
plugins.beautylog.log("now compiling" + " ts/test.ts".blue);
|
||||
plugins.gulp.src(paths.testTS)
|
||||
var stream = plugins.gulp.src(paths.testTS)
|
||||
.pipe(plugins.g.typescript({
|
||||
out: "test.js"
|
||||
}))
|
||||
.pipe(plugins.gulp.dest(paths.testDir))
|
||||
.pipe(plugins.gulp.dest(paths.testDir));
|
||||
return stream;
|
||||
});
|
||||
|
||||
plugins.gulp.task("defaultCleanup",function(cb){
|
||||
plugins.beautylog.success("TypeScript for this module compiled successfully.");
|
||||
plugins.beautylog.success("default TypeScript for this module compiled successfully.");
|
||||
done.resolve();
|
||||
cb();
|
||||
});
|
||||
|
||||
plugins.gulp.task("default",function(cb){
|
||||
plugins.g.sequence("defaultIndexTS","defaultTestTS","defaultCleanup",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']);
|
||||
|
@ -1,8 +1,29 @@
|
||||
/// <reference path="./index.ts" />
|
||||
module NpmtsOptions {
|
||||
export var config:any = {};
|
||||
export var run = function(){
|
||||
var done = plugins.q.defer();
|
||||
done.resolve(); //TODO: check for options
|
||||
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;
|
||||
}
|
||||
}
|
@ -11,11 +11,13 @@ module NpmtsPlugins {
|
||||
typescript: require("gulp-typescript")
|
||||
|
||||
},
|
||||
mathjs: require("mathjs"),
|
||||
mergeStream: require("merge2"),
|
||||
mocha: require("mocha"),
|
||||
path: require("path"),
|
||||
q:require("q"),
|
||||
smartcli: require("smartcli"),
|
||||
smartfile: require("smartfile"),
|
||||
typings: require("typings")
|
||||
};
|
||||
return plugins;
|
||||
|
@ -3,8 +3,8 @@ module NpmtsPromisechain {
|
||||
export var init = function(){
|
||||
var promisechain;
|
||||
NpmtsOptions.run()
|
||||
.then(NpmtsTypings.run)
|
||||
.then(NpmtsDefault.run)
|
||||
.then(NpmtsCustom.run)
|
||||
.then(NpmtsTests.run);
|
||||
return promisechain;
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
/// <reference path="./index.ts" />
|
||||
module NpmtsTypings {
|
||||
export var run = function(){
|
||||
var done = plugins.q.defer();
|
||||
plugins.beautylog.log("now installing typings");
|
||||
plugins.typings.install({production: false, cwd: paths.tsDir})
|
||||
.then(function(){
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user