major update

This commit is contained in:
Philipp Kunz 2016-01-31 22:24:57 +01:00
parent 8fb4a60fb3
commit 362f8d5388
24 changed files with 2418 additions and 99 deletions

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() {
var tsResult = plugins.gulp.src('../ts/index.ts')

9
index.d.ts vendored
View File

@ -1,4 +1,4 @@
/// <reference path="../ts/typings/tsd.d.ts" />
/// <reference path="../ts/typings/main.d.ts" />
declare module NpmtsPlugins {
var init: () => {
beautylog: any;
@ -7,7 +7,6 @@ declare module NpmtsPlugins {
g: {
insert: any;
sequence: any;
tsd: any;
typescript: any;
};
mergeStream: any;
@ -15,6 +14,7 @@ declare module NpmtsPlugins {
path: any;
q: any;
smartcli: any;
typings: any;
};
}
declare module NpmtsPaths {
@ -23,6 +23,9 @@ declare module NpmtsPaths {
declare module NpmtsOptions {
var run: () => any;
}
declare module NpmtsTypings {
var run: () => any;
}
declare module NpmtsDefault {
var run: () => any;
}
@ -39,7 +42,6 @@ declare var plugins: {
g: {
insert: any;
sequence: any;
tsd: any;
typescript: any;
};
mergeStream: any;
@ -47,6 +49,7 @@ declare var plugins: {
path: any;
q: any;
smartcli: any;
typings: any;
};
declare var paths: any;
declare var promisechain: any;

View File

@ -6,19 +6,19 @@ var NpmtsPlugins;
NpmtsPlugins.init = function () {
var plugins = {
beautylog: require("beautylog"),
fs: require("fs"),
fs: require("fs-extra"),
gulp: require("gulp"),
g: {
insert: require("gulp-insert"),
sequence: require("gulp-sequence"),
tsd: require("gulp-tsd"),
typescript: require("gulp-typescript")
},
mergeStream: require("merge2"),
mocha: require("mocha"),
path: require("path"),
q: require("q"),
smartcli: require("smartcli")
smartcli: require("smartcli"),
typings: require("typings")
};
return plugins;
};
@ -30,7 +30,7 @@ var NpmtsPaths;
NpmtsPaths.init = function () {
var paths = {};
paths.cwd = plugins.smartcli.get.cwd().path;
paths.tsd = plugins.path.join(paths.cwd, "ts/tsd.json");
paths.tsDir = plugins.path.join(paths.cwd, "ts/");
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
paths.testDir = plugins.path.join(paths.cwd, "test/");
@ -47,24 +47,24 @@ var NpmtsOptions;
};
})(NpmtsOptions || (NpmtsOptions = {}));
/// <reference path="./index.ts" />
var NpmtsTypings;
(function (NpmtsTypings) {
NpmtsTypings.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;
};
})(NpmtsTypings || (NpmtsTypings = {}));
/// <reference path="./index.ts" />
/// <reference path="./index.ts" />
var NpmtsDefault;
(function (NpmtsDefault) {
NpmtsDefault.run = function () {
var done = plugins.q.defer();
plugins.gulp.task("defaultTsd", function (cb) {
if (!process.env.TRAVIS) {
plugins.g.tsd({
command: 'reinstall',
config: paths.tsd
}, cb);
plugins.beautylog.log("now installing typings from" + " ts/tsd.json".blue);
}
else {
plugins.beautylog.warn("We are on TRAVIS. Typings will not be installed due to GitHub API restrictions.");
plugins.beautylog.log("Make sure the repo tracks " + "typings".blue + " directories");
}
});
plugins.gulp.task("defaultIndexTS", function () {
plugins.beautylog.log("now compiling" + " ts/index.ts".blue);
var tsResult = plugins.gulp.src(paths.indexTS)
@ -93,7 +93,7 @@ var NpmtsDefault;
cb();
});
plugins.gulp.task("default", function (cb) {
plugins.g.sequence("defaultTsd", "defaultIndexTS", "defaultTestTS", "defaultCleanup", cb);
plugins.g.sequence("defaultIndexTS", "defaultTestTS", "defaultCleanup", cb);
});
plugins.gulp.start.apply(plugins.gulp, ['default']);
return done.promise;
@ -104,16 +104,15 @@ 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");
// Instantiate a Mocha instance.
var mocha = new plugins.mocha();
var testDir = paths.testDir;
var mocha = new plugins.mocha(); // Instantiate a Mocha instance.
// Add each .js file to the mocha instance
plugins.fs.readdirSync(testDir).filter(function (file) {
plugins.fs.readdirSync(paths.testDir).filter(function (file) {
// Only keep the .js files
return file.substr(-3) === '.js';
}).forEach(function (file) {
mocha.addFile(plugins.path.join(testDir, file));
mocha.addFile(plugins.path.join(paths.testDir, file));
});
// Run the tests.
mocha.run(function (failures) {
@ -130,20 +129,23 @@ var NpmtsPromisechain;
NpmtsPromisechain.init = function () {
var promisechain;
NpmtsOptions.run()
.then(NpmtsTypings.run)
.then(NpmtsDefault.run)
.then(NpmtsTests.run);
return promisechain;
};
})(NpmtsPromisechain || (NpmtsPromisechain = {}));
/// <reference path="./typings/tsd.d.ts" />
/// <reference path="./typings/main.d.ts" />
/// <reference path="./npmts.plugins.ts" />
/// <reference path="./npmts.cli.ts" />
/// <reference path="./npmts.paths.ts" />
/// <reference path="./npmts.options.ts" />
/// <reference path="./npmts.typings.ts" />
/// <reference path="./npmts.custom.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 paths = NpmtsPaths.init();
var promisechain = NpmtsPromisechain.init();

View File

@ -28,14 +28,16 @@
"homepage": "https://github.com/pushrocks/npmts#readme",
"dependencies": {
"beautylog": "2.0.2",
"fs-extra": "^0.26.5",
"gulp": "3.9.0",
"gulp-insert": "0.5.0",
"gulp-sequence": "^0.4.4",
"gulp-tsd": "^0.1.0",
"gulp-typescript": "2.10.0",
"gulp-typings": "0.0.0",
"merge2": "0.3.6",
"mocha": "^2.4.5",
"q": "^1.4.1",
"smartcli": "0.0.11"
"smartcli": "0.0.11",
"typings": "^0.6.3"
}
}

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"
}
}
}

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,13 +1,14 @@
/// <reference path="./typings/tsd.d.ts" />
/// <reference path="./typings/main.d.ts" />
/// <reference path="./npmts.plugins.ts" />
/// <reference path="./npmts.cli.ts" />
/// <reference path="./npmts.paths.ts" />
/// <reference path="./npmts.options.ts" />
/// <reference path="./npmts.typings.ts" />
/// <reference path="./npmts.custom.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 paths = NpmtsPaths.init();
var promisechain = NpmtsPromisechain.init();

View File

@ -3,19 +3,6 @@
module NpmtsDefault {
export var run = function() {
var done = plugins.q.defer();
plugins.gulp.task("defaultTsd",function(cb){
if(!process.env.TRAVIS) {
plugins.g.tsd({
command: 'reinstall',
config: paths.tsd
}, cb);
plugins.beautylog.log("now installing typings from" + " ts/tsd.json".blue);
} else {
plugins.beautylog.warn("We are on TRAVIS. Typings will not be installed due to GitHub API restrictions.");
plugins.beautylog.log("Make sure the repo tracks " + "typings".blue + " directories")
}
});
plugins.gulp.task("defaultIndexTS", function(){
@ -50,7 +37,7 @@ module NpmtsDefault {
});
plugins.gulp.task("default",function(cb){
plugins.g.sequence("defaultTsd","defaultIndexTS","defaultTestTS","defaultCleanup",cb);
plugins.g.sequence("defaultIndexTS","defaultTestTS","defaultCleanup",cb);
});
plugins.gulp.start.apply(plugins.gulp, ['default']);

View File

@ -3,7 +3,7 @@ module NpmtsPaths {
export var init = function() {
var paths:any = {};
paths.cwd = plugins.smartcli.get.cwd().path;
paths.tsd = plugins.path.join(paths.cwd,"ts/tsd.json");
paths.tsDir = plugins.path.join(paths.cwd,"ts/");
paths.indexTS = plugins.path.join(paths.cwd,"ts/index.ts");
paths.testTS = plugins.path.join(paths.cwd,"ts/test.ts");
paths.testDir = plugins.path.join(paths.cwd,"test/");

View File

@ -3,12 +3,11 @@ module NpmtsPlugins {
export var init = function() {
var plugins = {
beautylog: require("beautylog"),
fs: require("fs"),
fs: require("fs-extra"),
gulp: require("gulp"),
g: {
insert: require("gulp-insert"),
sequence: require("gulp-sequence"),
tsd: require("gulp-tsd"),
typescript: require("gulp-typescript")
},
@ -16,7 +15,8 @@ module NpmtsPlugins {
mocha: require("mocha"),
path: require("path"),
q:require("q"),
smartcli: require("smartcli")
smartcli: require("smartcli"),
typings: require("typings")
};
return plugins;
}

View File

@ -3,6 +3,7 @@ module NpmtsPromisechain {
export var init = function(){
var promisechain;
NpmtsOptions.run()
.then(NpmtsTypings.run)
.then(NpmtsDefault.run)
.then(NpmtsTests.run);
return promisechain;

View File

@ -2,20 +2,18 @@
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");
// Instantiate a Mocha instance.
var mocha = new plugins.mocha();
var testDir = paths.testDir;
var mocha = new plugins.mocha(); // Instantiate a Mocha instance.
// Add each .js file to the mocha instance
plugins.fs.readdirSync(testDir).filter(function(file){
plugins.fs.readdirSync(paths.testDir).filter(function(file){
// Only keep the .js files
return file.substr(-3) === '.js';
}).forEach(function(file){
mocha.addFile(
plugins.path.join(testDir, file)
plugins.path.join(paths.testDir, file)
);
});

12
ts/npmts.typings.ts Normal file
View File

@ -0,0 +1,12 @@
/// <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;
}
}

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
// Project: https://github.com/Marak/colors.js
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>

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
// Project: http://nodejs.org/
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>, DefinitelyTyped <https://github.com/borisyankov/DefinitelyTyped>

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
// Project: https://github.com/wearefractal/vinyl
// Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module 'vinyl' {

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" />