Compare commits

...

142 Commits

Author SHA1 Message Date
45f9674550 5.0.3 2016-04-05 00:54:19 +02:00
eae983b271 now everything working again 2016-04-05 00:54:01 +02:00
871990725d 5.0.2 2016-04-05 00:45:56 +02:00
d46bb18893 update deps 2016-04-05 00:45:50 +02:00
d8fb9747cd 5.0.1 2016-04-05 00:31:25 +02:00
53209b18a9 update des 2016-04-05 00:31:17 +02:00
3e3561f4bb 5.0.0 2016-04-04 23:19:50 +02:00
099b513e0a update deps 2016-04-04 23:19:34 +02:00
cf15c428c1 4.0.3 2016-04-04 22:58:08 +02:00
3bd876a201 update deps 2016-04-04 22:57:50 +02:00
af62f20614 4.0.2 2016-04-04 16:57:13 +02:00
69eba08b27 updated log message 2016-04-04 16:57:09 +02:00
6635265f4b added codecov badge 2016-04-02 19:36:46 +02:00
ebdda5f969 4.0.1 2016-04-02 19:22:17 +02:00
f3a24154b4 now publishing coverage every time on travis since codecov does a good job sorting anything unwanted out 2016-04-02 19:22:01 +02:00
2980b6b5f3 4.0.0 2016-04-02 19:09:41 +02:00
570046ff67 switched from coveralls to codecov 2016-04-02 19:09:11 +02:00
112ce2d0d6 add author note 2016-04-02 01:25:01 +02:00
791eaefe3c better log messages 2016-04-02 01:20:52 +02:00
a3af90844a 3.6.10 2016-03-30 15:26:57 +02:00
e389f78256 more cosmetics 2016-03-30 15:26:53 +02:00
9e8fc76623 better wording 2016-03-30 01:35:20 +02:00
bf20ad9e61 3.6.9 2016-03-30 01:32:45 +02:00
58043d0fa2 now has better coverage failure 2016-03-30 01:32:41 +02:00
5b0814520a 3.6.8 2016-03-27 12:34:56 +02:00
848d40eeac update readme 2016-03-27 12:32:55 +02:00
73f5a0b055 3.6.7 2016-03-26 18:06:38 +01:00
f2a169ac7d added better Test log identifier 2016-03-26 18:06:29 +01:00
3cdd22044e 3.6.6 2016-03-26 17:36:00 +01:00
60d200135e fix small promise error 2016-03-26 17:35:55 +01:00
e8238dc907 3.6.5 2016-03-26 17:26:48 +01:00
007e7539c8 removed redundant if 2016-03-26 17:25:45 +01:00
e3c2c56548 3.6.4 2016-03-26 14:08:56 +01:00
f0954b19e0 improved execution order 2016-03-26 14:08:48 +01:00
48a9d19b8e 3.6.3 2016-03-23 15:55:12 +01:00
7d39683972 fix doPublish function 2016-03-23 15:55:07 +01:00
01e9f386a6 3.6.2 2016-03-23 15:47:34 +01:00
2f4fb28b5d made options handling easier 2016-03-23 15:47:28 +01:00
50b14e60c6 3.6.1 2016-03-23 15:23:14 +01:00
4753a4ff82 fix small error 2016-03-23 15:23:04 +01:00
fe9ea47208 3.6.0 2016-03-23 14:13:09 +01:00
c8f29dc146 now correctly determining release builds 2016-03-23 14:12:58 +01:00
e7e228c900 now cleaning up 2016-03-21 01:07:34 +01:00
b76cb1376d update deps 2016-03-20 19:09:58 +01:00
eed1a65415 add some beauty 2016-03-14 04:53:35 +01:00
040100b73f 3.5.0 2016-03-14 04:33:10 +01:00
3ce49c7e97 now handling cli option 2016-03-14 04:32:52 +01:00
55d7018891 add ship 2016-03-12 11:09:54 +01:00
d98d035902 3.4.1 2016-03-12 10:26:53 +01:00
217af24d25 fixs some cosmetics 2016-03-12 10:26:42 +01:00
11c43f59d9 update devDeps 2016-03-12 10:23:32 +01:00
14c36dd894 3.4.0 2016-03-12 10:21:34 +01:00
9f74fab2b2 now using gulp-typings 2016-03-12 10:21:16 +01:00
8efa67a4ff 3.3.2 2016-02-25 08:39:48 +01:00
f7304f59a5 add optional docs publishing 2016-02-25 08:39:38 +01:00
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
db63e07fa3 3.2.0 2016-02-23 17:27:12 +01:00
be65ee65cb fix errors 2016-02-23 17:27:07 +01:00
78bbe2d1d7 update travis tests 2016-02-23 15:43:18 +01:00
3960cd9973 more cleanup 2016-02-22 22:38:26 +01:00
0bad43d726 cleanup 2016-02-22 22:22:39 +01:00
d5407e33dd now using commonjs module system 2016-02-20 00:53:23 +01:00
2035045aef 3.1.2 2016-02-19 01:38:24 +01:00
de0f8cfb8b add gulp-header as dev-dependency 2016-02-19 01:37:39 +01:00
fe7d2f1024 3.1.1 2016-02-19 01:29:52 +01:00
9f0343b01c add new test files 2016-02-19 01:29:45 +01:00
04a02f6b96 fix obsolete old dependency 2016-02-19 01:28:57 +01:00
cb3f343c92 3.1.0 2016-02-19 01:24:46 +01:00
6227e47037 straighten up ts compilation 2016-02-19 01:24:25 +01:00
2730ca4299 3.0.3 2016-02-18 22:43:50 +01:00
07aae64965 fix sourcemaps 2016-02-18 22:43:40 +01:00
56841d5bb0 3.0.2 2016-02-18 12:55:35 +01:00
40301ede35 disable declaration files for now 2016-02-18 12:55:24 +01:00
70213b04bc disable declaration files for now 2016-02-18 12:55:00 +01:00
5160aab180 3.0.1 2016-02-17 06:04:02 +01:00
e8806e548b fix coverage 2016-02-17 06:00:12 +01:00
fcdaad540e fix coverage 2016-02-17 05:59:29 +01:00
6f33b1f5ef 3.0.0 2016-02-17 05:51:55 +01:00
45418d6049 update test 2016-02-17 05:51:51 +01:00
4261ee3687 cleanup 2016-02-17 05:50:12 +01:00
9fc3606163 cleanup 2016-02-17 05:49:10 +01:00
2436b30605 update default behaviour 2016-02-17 05:45:42 +01:00
9ad59704be 2.4.1 2016-02-17 04:26:44 +01:00
29f3832d63 switch to commonjs module as default 2016-02-17 04:26:26 +01:00
2d82a3a037 2.4.0 2016-02-17 01:48:38 +01:00
4806f5ceff updated readme 2016-02-17 01:40:01 +01:00
f2ef982189 added sourcemap support 2016-02-17 01:16:21 +01:00
5d6ead017b 2.3.2 2016-02-16 11:29:07 +01:00
1c2b4e421d fix compile script 2016-02-16 11:28:57 +01:00
6cf7d2ca0b update test 2016-02-16 11:14:05 +01:00
676c072631 2.3.1 2016-02-16 10:58:50 +01:00
f29c04e09c update .gitignore 2016-02-16 10:58:42 +01:00
77a06a0fc4 2.3.0 2016-02-16 10:29:26 +01:00
c9792b1955 update target from ES3 to ES5 2016-02-16 10:29:14 +01:00
b87de178c0 2.2.4 2016-02-16 09:53:35 +01:00
0580f29d30 update ReadeMe 2016-02-16 09:52:24 +01:00
2c17273671 update badge order 2016-02-14 03:20:53 +01:00
669ed2e6ab add badges 2016-02-14 03:19:54 +01:00
8bc73b2bf4 update readme 2016-02-14 03:13:03 +01:00
78e5defd7c update readme 2016-02-14 03:12:02 +01:00
7e540bda87 2.2.3 2016-02-11 19:10:14 +01:00
b293dfe92d add figlet greeting 2016-02-11 19:10:01 +01:00
a753a5db2c 2.2.2 2016-02-09 20:36:40 +01:00
27f79b4425 readded test.ts to default build process 2016-02-09 20:36:31 +01:00
1ada5dd5a9 2.2.1 2016-02-09 17:42:43 +01:00
a41bfd442c fix coveralls initial value 2016-02-09 17:42:31 +01:00
2917b10ffb 2.2.0 2016-02-09 17:26:37 +01:00
bfc5bbbbb7 fix coverage path 2016-02-09 17:26:25 +01:00
cf507a4a17 add coverage badge 2016-02-09 17:19:27 +01:00
73a57ed264 2.1.10 2016-02-09 17:01:45 +01:00
39b79b679c fix config traveling 2016-02-09 17:01:37 +01:00
cc053ee396 2.1.9 2016-02-09 16:34:55 +01:00
df5371187b remove scoping problem with gulp task names 2016-02-09 16:34:52 +01:00
cbda76c380 2.1.8 2016-02-09 16:00:20 +01:00
e20bcec133 finetune some paths 2016-02-09 16:00:07 +01:00
3e673e04b2 2.1.7 2016-02-09 06:01:39 +01:00
2090dad540 refine coverage treshold for failure 2016-02-09 06:01:32 +01:00
ebe7a02ef0 2.1.6 2016-02-09 05:47:11 +01:00
3f9194f344 add coveralls config option 2016-02-09 05:46:55 +01:00
13c9c96cc6 add code coverage 2016-02-09 05:39:31 +01:00
3f0b2b1599 2.1.5 2016-02-07 12:19:50 +01:00
d477e492eb small fix 2016-02-07 12:19:42 +01:00
f39cb03fc2 2.1.4 2016-02-07 01:00:28 +01:00
f42744b927 2.1.3 2016-02-06 19:00:20 +01:00
038994e9e5 updated log output 2016-02-06 19:00:02 +01:00
7a26721420 2.1.2 2016-02-06 18:56:51 +01:00
0dc307f082 now handles multiple typings recursivly 2016-02-06 18:56:42 +01:00
4b2c0fe461 2.1.1 2016-02-06 18:07:20 +01:00
50fd5e83ad improve path handling 2016-02-06 18:06:55 +01:00
3e55a666b2 update npm test 2016-02-04 20:43:52 +01:00
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
79 changed files with 1182 additions and 5077 deletions

12
.gitignore vendored
View File

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

View File

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

View File

@ -1,6 +1,7 @@
language: node_js
node_js:
- "4.2.4"
- 4.3.1
- stable
deploy:
provider: npm
email: npm@lossless.digital
@ -9,3 +10,6 @@ deploy:
on:
tags: true
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=

View File

@ -1 +0,0 @@
# README-dev

View File

@ -1,7 +1,15 @@
# npmts
Write npm modules with TypeScript without hassle.
## How to use npmts
## Status
[![Build Status](https://travis-ci.org/pushrocks/npmts.svg?branch=master)](https://travis-ci.org/pushrocks/npmts)
[![Dependency Status](https://david-dm.org/pushrocks/npmts.svg)](https://david-dm.org/pushrocks/npmts)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/npmts/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/npmts/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/npmts/badges/code.svg)](https://www.bithound.io/github/pushrocks/npmts)
[![codecov.io](https://codecov.io/github/pushrocks/npmts/coverage.svg?branch=master)](https://codecov.io/github/pushrocks/npmts?branch=master)
## What is NPMTS?
NPMTS is your friend when it comes to write, test, publish and document NPM modules written in TypeScript.
### Install
First install npmts as dev dependency:
@ -19,8 +27,33 @@ Then use it in package.json's script section to trigger a build:
```
### Default behaviour
by default npmts looks for `./ts/index.ts` and `./ts/test.ts` that will compile to
`./index.js` and `./test.js`
**Execution order of tasks**
1. Check config in ./npmts.json
1. Clean up from any previous builds (old js files)
1. Install typings
1. Transpile TypeScript with inline sourcemaps
1. Create Declaration Files
1. Create JsDoc Documentation
1. Instrumentalize created JavaScript files with istanbul
1. Run Tests
1. Create Coverage report
1. Upload Coverage reports to codecov.io (Tests must pass, codecov.io must be activated, by default only triggers on travis)
1. Upload JsDoc Documentation to gh-pages branch on GitHub. (Tests must pass, requires GitHub Token)
#### npmts.json
the npmts.json is the main config file. You can use it to customize the behaviour of NPMTS.
#### Typings
**npmts** looks for `./ts/typings.json` by default and installs any defined typings to `.ts/typings/`.
You can then reference the ./ts/typings/main.d.ts file in any of your TypeScript code.
#### TypeScript
by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
`./dist/*.js` and `./test/test.js`
Use commonjs module system for wiring up files.
#### Declaration files
**npmts** also creates an `index.d.ts` declaration file by default.
@ -31,15 +64,43 @@ You can reference it in your package.json like this:
"typings": "./index.d.ts",
```
When requiring the module from other TypeScript files,
the TypeScript Compiler will use the declaration file to resolve typings.
You can then import plugins via the TypeScript `import` Syntax
and tsc will pick up the declaration file automatically.
#### Instrumentalize Code
npmts instrumentalizes (using istanbul) the created JavaScript code to create a coverage report.
#### Tests
When Typings have been installed, TypeScript + Declaration files have been transpiled and the resulting JS has been instrumentalized,
npmts looks for `.test/test.ts` which will be transpiled to test.js and run with mocha.
Any errors will be shown with reference to their originating source in TypeScript
thanks to autogenerated source maps.
### Custom behaviour
We are currently building support for custom behaviour with a super simple config file.
Check back soon.
Custom behaviour can be achieved through the npmts.json config file at the root of your package.
The file must be named **npmts.json**
## Readme for Devs
There is a [README-dev.md](README-dev.md) in the repo.
This is only of interest for you when looking to contribute to, improve or build upon this 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.
> We will add more options over time.
### About the authors:
[![Project Phase](https://mediaserve.lossless.digital/lossless.com/img/createdby_github.svg)](https://lossless.com/)
[![PayPal](https://img.shields.io/badge/Support%20us-PayPal-blue.svg)](https://paypal.me/lossless)

2
assets/cli.js Normal file
View File

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

1
assets/node-shebang.js Normal file
View File

@ -0,0 +1 @@
#!/usr/bin/env node

View File

@ -4,31 +4,45 @@ var plugins = {
gulp: require("gulp"),
g:{
typescript: require("gulp-typescript"),
insert: require("gulp-insert")
typings:require("gulp-typings")
},
mergeStream: require("merge2")
mergeStream: require("merge2"),
path: require("path")
};
paths = {
packageBase: plugins.path.resolve(
plugins.path.join(__dirname,"../")
)
};
plugins.beautylog.log('now compiling NPMTS');
plugins.gulp.task('indexTS', function() {
var tsResult = plugins.gulp.src('../ts/index.ts')
.pipe(plugins.g.typescript({
out:"index.js",
declaration:true
}));
return plugins.mergeStream([
tsResult.dts.pipe(plugins.gulp.dest('../')),
tsResult.js
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest('../'))
]);
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('default',['indexTS'], function() {
plugins.gulp.task("TS",["typings"], function() {
var stream = plugins.gulp.src([
plugins.path.join(paths.packageBase,'ts/**/*.ts'),
"!" + plugins.path.join(paths.packageBase,'ts/typings/**/*.d.ts')
])
.pipe(plugins.g.typescript({
target:"ES5",
module:"commonjs"
}))
.pipe(plugins.gulp.dest(plugins.path.join(paths.packageBase, 'dist/')));
return stream;
});
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');
});

2
dist/cli.js vendored Normal file
View File

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

12
dist/index.js vendored Normal file
View File

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

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

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

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

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

1
dist/npmts.cli.js vendored Normal file
View File

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

62
dist/npmts.compile.js vendored Normal file
View File

@ -0,0 +1,62 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
plugins.beautylog.log("now compiling " + "TypeScript".yellow);
var moduleStream = plugins.merge2({ end: false });
/* -------------------------------------------------
* ----------- compile TypeScript --------------------------
* ----------------------------------------------- */
for (var key in config.ts) {
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 () {
plugins.beautylog.ok("TypeScript has been compiled!");
moduleStream.on("finish", function () {
done.resolve(config);
});
moduleStream.end();
});
/*==================== END TYPESCRIPT =====================*/
return done.promise;
};

31
dist/npmts.configfile.js vendored Normal file
View File

@ -0,0 +1,31 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
exports.run = function () {
var done = plugins.Q.defer();
var config = {};
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.local.toObjectSync(configPath);
switch (config.mode) {
case "default":
case "custom":
plugins.beautylog.ok("mode is " + config.mode.yellow);
done.resolve(config);
break;
default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
}
;
}
else {
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
config.mode = "default";
done.resolve(config);
}
;
return done.promise;
};

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

@ -0,0 +1,20 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
exports.run = function (configArg) {
var config = configArg;
var done = plugins.Q.defer();
/* -------------------------------------------------
* ----------- install typings ---------------
* ----------------------------------------------- */
plugins.beautylog.log("now installing " + "typings".yellow);
var absoluteTypingsArray = plugins.smartpath.transform.toAbsolute(config.typings, paths.cwd);
plugins.gulp.src(absoluteTypingsArray)
.pipe(plugins.g.typings())
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("typings have been installed!");
done.resolve(config);
}, "atEnd"));
return done.promise;
};

55
dist/npmts.jsdoc.js vendored Normal file
View File

@ -0,0 +1,55 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var genJsdoc = function (configArg) {
var done = plugins.Q.defer();
plugins.beautylog.log("now generating " + "JsDoc documentation".blue);
plugins.gulp.src([
plugins.path.join(paths.cwd, "README.md"),
plugins.path.join(paths.distDir, "**/*.js")
])
.pipe(plugins.g.jsdoc3({
opts: {
destination: paths.docsDir
}
}, function () {
plugins.beautylog.ok("JsDoc documentation has been generated!");
done.resolve(configArg);
}));
return done.promise;
};
exports.publishDocs = function (configArg) {
var done = plugins.Q.defer();
var gitUrl = plugins.projectinfo.npm(paths.cwd, {
gitAccessToken: process.env.GITHUB_TOKEN
}).git.httpsUrl;
var deployScript = ""
+ "cd " + paths.docsDir + " "
+ "&& git init " + "> /dev/null 2>&1 "
+ "&& git config user.name \"TRAVIS CI\" " + "> /dev/null 2>&1 "
+ "&& git config user.email \"travis@shipzone.io\" " + "> /dev/null 2>&1 "
+ "&& git add . " + "> /dev/null 2>&1 "
+ "&& git commit -m \"Deploy to GitHub Pages\" " + "> /dev/null 2>&1 "
+ "&& git push --force --quiet "
+ "\"" + gitUrl + "\" "
+ "master:gh-pages " + "> /dev/null 2>&1";
plugins.beautylog.log("now publishing JsDoc documentation to GitHub");
if (!plugins.shelljs.which('git')) {
plugins.beautylog.error('Git is not installed!');
plugins.shelljs.exit(1);
}
else if (plugins.shelljs.exec(deployScript).code !== 0) {
plugins.beautylog.error('Git failed!');
plugins.shelljs.exit(1);
}
plugins.beautylog.ok("JsDoc documentation has been deployed to GitHub!");
done.resolve(configArg);
return done.promise;
};
exports.run = function (configArg) {
var done = plugins.Q.defer();
genJsdoc(configArg)
.then(done.resolve);
return done.promise;
};

48
dist/npmts.options.js vendored Normal file
View File

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

16
dist/npmts.paths.js vendored Normal file
View File

@ -0,0 +1,16 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = {};
paths.cwd = plugins.smartcli.get.cwd().path;
//Directories
paths.tsDir = plugins.path.join(paths.cwd, "ts/");
paths.distDir = plugins.path.join(paths.cwd, "dist/");
paths.docsDir = plugins.path.join(paths.cwd, "docs/");
paths.testDir = plugins.path.join(paths.cwd, "test/");
paths.coverageDir = plugins.path.join(paths.cwd, "coverage/");
paths.npmtsAssetsDir = plugins.path.join(__dirname, "../assets/");
//Files
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
module.exports = paths;

27
dist/npmts.plugins.js vendored Normal file
View File

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

48
dist/npmts.promisechain.js vendored Normal file
View File

@ -0,0 +1,48 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var NpmtsAssets = require("./npmts.assets");
var NpmtsClean = require("./npmts.clean");
var NpmtsCompile = require("./npmts.compile");
var NpmtsConfigFile = require("./npmts.configfile");
var NpmtsInstall = require("./npmts.install");
var NpmtsJsdoc = require("./npmts.jsdoc");
var NpmtsOptions = require("./npmts.options");
var NpmtsPublish = require("./npmts.publish");
var NpmtsTests = require("./npmts.tests");
exports.run = function () {
var promisechain;
NpmtsConfigFile.run()
.then(NpmtsOptions.run)
.then(NpmtsClean.run)
.then(NpmtsInstall.run)
.then(NpmtsCompile.run)
.then(NpmtsAssets.run)
.then(NpmtsJsdoc.run)
.then(NpmtsTests.run)
.then(NpmtsPublish.run)
.then(function (configArg) {
var shipString = "" +
"\n" +
"\n" +
" # # ( )\n" +
" ___#_#___|__\n" +
" _ |____________| _\n" +
" _=====| | | | | |==== _\n" +
" =====| |.---------------------------. | |====\n" +
" <--------------------' . . . . . . . . '--------------/\n" +
" \\ /\n" +
" \\___________________________________________________________/\n" +
" wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n" +
" wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n" +
" wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n";
if (process.env.CI) {
console.log(shipString);
plugins.beautylog.success("READY TO SHIP!");
}
else {
plugins.beautylog.success("Done!");
}
});
return promisechain;
};

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

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

77
dist/npmts.tests.js vendored Normal file
View File

@ -0,0 +1,77 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
exports.publishCoverage = function (configArg) {
var done = plugins.Q.defer();
plugins.beautylog.log("now uploading coverage data to codecov.io");
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
.pipe(plugins.g.codecov())
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("Coverage data has been uploaded to codecov.io!");
done.resolve(configArg);
}, "atEnd"));
return done.promise;
};
/**
*
* @returns {*}
*/
var istanbul = function (configArg) {
var done = plugins.Q.defer();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
.pipe(plugins.g.istanbul()) // Covering files
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
.pipe(plugins.g.gFunction(function () {
done.resolve(configArg);
}, "atEnd"));
return done.promise;
};
/**
*
* @returns {*}
*/
var mocha = function (configArg) {
var done = plugins.Q.defer();
var stream = plugins.gulp.src(["./test/test.js"])
.pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("Tests have passed!");
done.resolve(configArg);
}, "atEnd"));
return done.promise;
};
var coverage = function (configArg) {
var done = plugins.Q.defer();
plugins.smartcov.get.percentage(plugins.path.join(paths.coverageDir, "lcov.info"))
.then(function (percentageArg) {
if (percentageArg >= configArg.coverageTreshold) {
plugins.beautylog.ok("your coverage of " + percentageArg.toString().blue + "% ".blue + "exceeds your treshold of " +
configArg.coverageTreshold.toString().blue + "%".blue);
}
else {
plugins.beautylog.warn("your coverage of " + percentageArg + "% " + "fails your treshold of " +
configArg.coverageTreshold + "%");
plugins.beautylog.error("exiting due to coverage failure");
process.exit(1);
}
done.resolve(configArg);
});
return done.promise;
};
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
plugins.beautylog.log("now starting tests");
console.log("--------------------------------------------------------------\n" +
"***************************" +
" TESTS: ".blue +
"***************************\n" +
"--------------------------------------------------------------");
istanbul(config)
.then(mocha)
.then(coverage)
.then(done.resolve);
return done.promise;
};

55
index.d.ts vendored
View File

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

145
index.js
View File

@ -1,145 +0,0 @@
#!/usr/bin/env node
/// <reference path="./index.ts" />
var NpmtsPlugins;
(function (NpmtsPlugins) {
NpmtsPlugins.init = function () {
var plugins = {
beautylog: require("beautylog"),
fs: require("fs-extra"),
gulp: require("gulp"),
g: {
insert: require("gulp-insert"),
sequence: require("gulp-sequence"),
typescript: require("gulp-typescript")
},
mergeStream: require("merge2"),
mocha: require("mocha"),
path: require("path"),
q: require("q"),
smartcli: require("smartcli"),
typings: require("typings")
};
return plugins;
};
})(NpmtsPlugins || (NpmtsPlugins = {}));
/// <reference path="./index.ts" />
/// <reference path="./index.ts" />
var NpmtsPaths;
(function (NpmtsPaths) {
NpmtsPaths.init = function () {
var paths = {};
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.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
paths.testDir = plugins.path.join(paths.cwd, "test/");
return paths;
};
})(NpmtsPaths || (NpmtsPaths = {}));
/// <reference path="./index.ts" />
var NpmtsOptions;
(function (NpmtsOptions) {
NpmtsOptions.run = function () {
var done = plugins.q.defer();
done.resolve(); //TODO: check for options
return done.promise;
};
})(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("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",
declaration: true
}));
return plugins.mergeStream([
tsResult.dts.pipe(plugins.gulp.dest(paths.cwd)),
tsResult.js
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest(paths.cwd))
]);
});
plugins.gulp.task("defaultTestTS", function () {
plugins.beautylog.log("now compiling" + " ts/test.ts".blue);
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.");
done.resolve();
cb();
});
plugins.gulp.task("default", function (cb) {
plugins.g.sequence("defaultIndexTS", "defaultTestTS", "defaultCleanup", cb);
});
plugins.gulp.start.apply(plugins.gulp, ['default']);
return done.promise;
};
})(NpmtsDefault || (NpmtsDefault = {}));
/// <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(NpmtsTypings.run)
.then(NpmtsDefault.run)
.then(NpmtsTests.run);
return promisechain;
};
})(NpmtsPromisechain || (NpmtsPromisechain = {}));
/// <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

@ -1,15 +1,13 @@
{
"name": "npmts",
"version": "2.0.3",
"version": "5.0.3",
"description": "write npm modules with TypeScript",
"main": "index.js",
"typings": "./index.d.ts",
"main": "dist/index.js",
"bin": {
"npmts": "./index.js"
"npmts": "dist/cli.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 ../../dist/index.js)",
"release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)"
},
"repository": {
@ -27,17 +25,30 @@
},
"homepage": "https://github.com/pushrocks/npmts#readme",
"dependencies": {
"beautylog": "2.0.6",
"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": "1.0.0",
"mocha": "^2.4.5",
"beautylog": "4.1.1",
"fs-extra": "^0.26.7",
"gulp": "3.9.1",
"gulp-codecov": "^2.0.1",
"gulp-concat": "^2.6.0",
"gulp-function": "^1.2.4",
"gulp-if": "^2.0.0",
"gulp-istanbul": "^0.10.3",
"gulp-jsdoc3": "^0.2.1",
"gulp-mocha": "^2.2.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-typescript": "2.12.2",
"gulp-typings": "1.3.1",
"merge2": "1.0.2",
"projectinfo": "1.0.1",
"q": "^1.4.1",
"shelljs": "^0.6.0",
"smartci": "0.0.1",
"smartcli": "0.0.11",
"typings": "^0.6.5"
}
"smartcov": "0.0.4",
"smartenv": "1.2.1",
"smartfile": "3.0.2",
"smartpath": "3.1.3",
"source-map-support": "^0.4.0"
},
"devDependencies": {}
}

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

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

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,2 @@
var something = "something";
//# sourceMappingURL=tsfile1.js.map

View File

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

View File

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

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

9
test/assets/dist/index.js vendored Normal file
View File

@ -0,0 +1,9 @@
/// <reference path="./typings/main.d.ts" />
var testplugin = {
logSomething: function () {
console.log("only function executed");
}
};
module.exports = testplugin;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxubGV0IHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

View File

View File

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

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

@ -0,0 +1,17 @@
{
"mode":"default",
"ts":{
"./customdir/*.ts":"./"
},
"typings":[
"./ts/typings.json",
"./subts1/typings.json",
"./subts2/typings.json",
"./customdir/typings.json"
],
"codecov":true,
"docs": {
"publish":true
},
"cli":true
}

View File

@ -1,13 +1,16 @@
{
"name": "test",
"version": "1.0.0",
"name": "testpackage",
"version": "2.0.0",
"description": "",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/pushrocks/npmts.git"
},
"scripts": {
"test": "(npmts)"
},
"author": "",
"license": "ISC",
"dependencies": {
}
"dependencies": {}
}

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

BIN
test/assets/test/.DS_Store vendored Normal file

Binary file not shown.

View File

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

View File

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

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

@ -0,0 +1,9 @@
/// <reference path="../ts/typings/main.d.ts" />
var testplugin = require("../dist/index.js");
describe("testplugins",function(){
describe(".logSomething",function(){
it("should log something",function(){
testplugin.logSomething()
});
});
});

View File

@ -0,0 +1,8 @@
{
"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,4 +1,8 @@
(function () {
console.log("test");
}());
/// <reference path="./typings/main.d.ts" />
var testplugin = {
logSomething: function () {
console.log("only function executed");
}
};
module.exports = testplugin;
//# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,CAAC;IACG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACvB,CAAC,EAAE,CAAC,CAAC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,IAAI,UAAU,GAAG;IACb,YAAY,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAC;AACF,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC"}

View File

@ -1,3 +1,7 @@
(function(){
console.log("test")
}());
/// <reference path="./typings/main.d.ts" />
let testplugin = {
logSomething: function(){
console.log("only function executed");
}
};
module.exports = testplugin;

View File

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

View File

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

View File

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

View File

@ -1,7 +1,8 @@
{
"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"
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts"
}
}

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

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

View File

@ -1,14 +1,13 @@
/// <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();
console.log("**** starting NPMTS ****");
import plugins = require("./npmts.plugins");
import promisechain = require("./npmts.promisechain");
plugins.beautylog.figletSync("NPMTS");
try {
promisechain.run();
}
catch(err){
console.log(err);
}

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

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

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

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

View File

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

69
ts/npmts.compile.ts Normal file
View File

@ -0,0 +1,69 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
export var run = function(configArg){
var done = plugins.Q.defer();
var config = configArg;
plugins.beautylog.log("now compiling " + "TypeScript".yellow);
var moduleStream = plugins.merge2({end: false});
/* -------------------------------------------------
* ----------- compile TypeScript --------------------------
* ----------------------------------------------- */
for (var key in config.ts) {
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
.pipe(plugins.g.typescript({
out: outputName,
target: "ES5",
module: "commonjs"
}))
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
//.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest(outputDir));
moduleStream.add(stream);
}
moduleStream.on("queueDrain",function(){
plugins.beautylog.ok("TypeScript has been compiled!");
moduleStream.on("finish",function(){
done.resolve(config);
});
moduleStream.end();
});
/*==================== END TYPESCRIPT =====================*/
return done.promise;
};

27
ts/npmts.configfile.ts Normal file
View File

@ -0,0 +1,27 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
export var run = function(){
var done = plugins.Q.defer();
var config:any = {};
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.local.toObjectSync(configPath);
switch (config.mode){
case "default":
case "custom":
plugins.beautylog.ok("mode is " + config.mode.yellow);
done.resolve(config);
break;
default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
};
} else {
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
config.mode = "default";
done.resolve(config);
};
return done.promise;
};

View File

@ -1 +0,0 @@
/// <reference path="./index.ts" />

View File

@ -1,47 +0,0 @@
/// <reference path="./index.ts" />
module NpmtsDefault {
export var run = function() {
var done = plugins.q.defer();
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",
declaration:true
}));
return plugins.mergeStream([
tsResult.dts.pipe(plugins.gulp.dest(paths.cwd)),
tsResult.js
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
.pipe(plugins.gulp.dest(paths.cwd))
]);
});
plugins.gulp.task("defaultTestTS", function(){
plugins.beautylog.log("now compiling" + " ts/test.ts".blue);
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.");
done.resolve();
cb();
});
plugins.gulp.task("default",function(cb){
plugins.g.sequence("defaultIndexTS","defaultTestTS","defaultCleanup",cb);
});
plugins.gulp.start.apply(plugins.gulp, ['default']);
return done.promise;
}
}

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

@ -0,0 +1,19 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
export var run = function(configArg){
var config = configArg;
var done = plugins.Q.defer();
/* -------------------------------------------------
* ----------- install typings ---------------
* ----------------------------------------------- */
plugins.beautylog.log("now installing " + "typings".yellow);
var absoluteTypingsArray = plugins.smartpath.transform.toAbsolute(config.typings,paths.cwd);
plugins.gulp.src(absoluteTypingsArray)
.pipe(plugins.g.typings())
.pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("typings have been installed!");
done.resolve(config);
},"atEnd"));
return done.promise;
};

64
ts/npmts.jsdoc.ts Normal file
View File

@ -0,0 +1,64 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
let genJsdoc = function(configArg){
let done = plugins.Q.defer();
plugins.beautylog.log("now generating " + "JsDoc documentation".blue);
plugins.gulp.src([
plugins.path.join(paths.cwd,"README.md"),
plugins.path.join(paths.distDir,"**/*.js")
])
.pipe(plugins.g.jsdoc3({
opts: {
destination: paths.docsDir
}
}, function(){
plugins.beautylog.ok("JsDoc documentation has been generated!");
done.resolve(configArg)
}));
return done.promise;
};
export let publishDocs = function(configArg){
let done = plugins.Q.defer();
let gitUrl = plugins.projectinfo.npm(
paths.cwd,
{
gitAccessToken:process.env.GITHUB_TOKEN
}
).git.httpsUrl;
let deployScript = ""
+ "cd " + paths.docsDir + " "
+ "&& git init " + "> /dev/null 2>&1 "
+ "&& git config user.name \"TRAVIS CI\" " + "> /dev/null 2>&1 "
+ "&& git config user.email \"travis@shipzone.io\" " + "> /dev/null 2>&1 "
+ "&& git add . " + "> /dev/null 2>&1 "
+ "&& git commit -m \"Deploy to GitHub Pages\" " + "> /dev/null 2>&1 "
+ "&& git push --force --quiet "
+ "\"" + gitUrl + "\" "
+ "master:gh-pages " + "> /dev/null 2>&1";
plugins.beautylog.log("now publishing JsDoc documentation to GitHub");
if (!plugins.shelljs.which('git')) {
plugins.beautylog.error('Git is not installed!');
plugins.shelljs.exit(1);
} else if (plugins.shelljs.exec(deployScript).code !== 0) {
plugins.beautylog.error('Git failed!');
plugins.shelljs.exit(1);
}
plugins.beautylog.ok("JsDoc documentation has been deployed to GitHub!");
done.resolve(configArg);
return done.promise;
};
export let run = function(configArg){
let done = plugins.Q.defer();
genJsdoc(configArg)
.then(done.resolve);
return done.promise;
};

View File

@ -1,8 +1,57 @@
/// <reference path="./index.ts" />
module NpmtsOptions {
export var run = function(){
var done = plugins.q.defer();
done.resolve(); //TODO: check for options
return done.promise;
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
export let isCi = function(){
return plugins.smartci.check.isCi();
};
export let isRelease = function():boolean {
return plugins.smartci.check.isCi()
&& plugins.smartci.check.isTaggedCommit();
};
export let doPublish = function():boolean {
return isRelease()
&& plugins.smartci.get.subJobNumber() == 1;
};
export var run = function(configArg){
var done = plugins.Q.defer();
var config = configArg;
plugins.beautylog.log("now determining build options...");
//handle default mode
if (config.mode == "default"){
config.typings = [
"./ts/typings.json"
];
config.ts = {
["./ts/**/*.ts"]: "./dist/",
["./test/test.ts"]: "./test/"
};
config.test = ["./index.js"];
}
}
// handle state of current build
isRelease() ? plugins.beautylog.info("All right: This is a RELEASE build!")
: plugins.beautylog.info("NOT A RELEASE build!");
isRelease() && doPublish() ? plugins.beautylog.info("All right: This is the first subBuild, so this one publishes COVERAGE + DOCS when tests succeed!")
: plugins.beautylog.info("We are not publishing anything!");
// handle coveralls
config.codecov ? void(0) : config.codecov = true;
isCi() ? void(0) : config.codecov = false;
config.coverageTreshold ? void(0) : config.coverageTreshold = 70;
// handle docs
config.docs ? void(0) : config.docs = {};
config.docs.publish ? void(0) : config.docs.publish = false;
doPublish() ? void(0) : config.docs.publish = false;
plugins.beautylog.ok("build options are ready!");
done.resolve(config);
return done.promise;
};

View File

@ -1,12 +1,19 @@
/// <reference path="./index.ts" />
module NpmtsPaths {
export var init = function() {
var paths:any = {};
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.testTS = plugins.path.join(paths.cwd,"ts/test.ts");
paths.testDir = plugins.path.join(paths.cwd,"test/");
return paths;
}
}
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
var paths:any = {};
paths.cwd = plugins.smartcli.get.cwd().path;
//Directories
paths.tsDir = plugins.path.join(paths.cwd,"ts/");
paths.distDir = plugins.path.join(paths.cwd,"dist/");
paths.docsDir = plugins.path.join(paths.cwd,"docs/");
paths.testDir = plugins.path.join(paths.cwd,"test/");
paths.coverageDir = plugins.path.join(paths.cwd,"coverage/");
paths.npmtsAssetsDir = plugins.path.join(__dirname,"../assets/");
//Files
paths.indexTS = plugins.path.join(paths.cwd,"ts/index.ts");
paths.testTS = plugins.path.join(paths.cwd,"ts/test.ts");
export = paths;

View File

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

View File

@ -1,11 +1,49 @@
/// <reference path="./index.ts" />
module NpmtsPromisechain {
export var init = function(){
var promisechain;
NpmtsOptions.run()
.then(NpmtsTypings.run)
.then(NpmtsDefault.run)
.then(NpmtsTests.run);
return promisechain;
}
}
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
import NpmtsAssets = require("./npmts.assets");
import NpmtsClean = require("./npmts.clean");
import NpmtsCompile = require("./npmts.compile");
import NpmtsConfigFile = require("./npmts.configfile");
import NpmtsInstall = require("./npmts.install");
import NpmtsJsdoc = require("./npmts.jsdoc");
import NpmtsOptions = require("./npmts.options");
import NpmtsPublish = require("./npmts.publish");
import NpmtsTests = require("./npmts.tests");
export var run = function(){
var promisechain;
NpmtsConfigFile.run()
.then(NpmtsOptions.run)
.then(NpmtsClean.run)
.then(NpmtsInstall.run)
.then(NpmtsCompile.run)
.then(NpmtsAssets.run)
.then(NpmtsJsdoc.run)
.then(NpmtsTests.run)
.then(NpmtsPublish.run)
.then(function(configArg){
let shipString = "" +
"\n" +
"\n" +
" # # ( )\n" +
" ___#_#___|__\n" +
" _ |____________| _\n" +
" _=====| | | | | |==== _\n" +
" =====| |.---------------------------. | |====\n" +
" <--------------------' . . . . . . . . '--------------/\n" +
" \\ /\n" +
" \\___________________________________________________________/\n" +
" wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n" +
" wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n" +
" wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n"
if (process.env.CI){
console.log(shipString);
plugins.beautylog.success("READY TO SHIP!");
} else {
plugins.beautylog.success("Done!")
}
});
return promisechain;
};

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

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

View File

@ -1,19 +1,88 @@
/// <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");
/// <reference path="./typings/main.d.ts" />
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
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);
});
export let publishCoverage = function(configArg){
let done = plugins.Q.defer();
plugins.beautylog.log("now uploading coverage data to codecov.io");
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
.pipe(plugins.g.codecov())
.pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("Coverage data has been uploaded to codecov.io!");
done.resolve(configArg);
},"atEnd"));
return done.promise;
};
/**
*
* @returns {*}
*/
let istanbul = function (configArg) {
let done = plugins.Q.defer();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
.pipe(plugins.g.istanbul()) // Covering files
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
.pipe(plugins.g.gFunction(function(){
done.resolve(configArg);
},"atEnd"));
return done.promise;
};
/**
*
* @returns {*}
*/
let mocha = function (configArg) {
let done = plugins.Q.defer();
let stream = plugins.gulp.src(["./test/test.js"])
.pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
.pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("Tests have passed!");
done.resolve(configArg);
},"atEnd"));
return done.promise;
};
let coverage = function(configArg){
let done = plugins.Q.defer();
plugins.smartcov.get.percentage(plugins.path.join(paths.coverageDir,"lcov.info"))
.then(function(percentageArg){
if (percentageArg >= configArg.coverageTreshold){
plugins.beautylog.ok(
"your coverage of " + percentageArg.toString().blue + "% ".blue + "exceeds your treshold of " +
configArg.coverageTreshold.toString().blue + "%".blue
);
} else {
plugins.beautylog.warn(
"your coverage of " + percentageArg + "% " + "fails your treshold of " +
configArg.coverageTreshold + "%"
);
plugins.beautylog.error("exiting due to coverage failure");
process.exit(1);
}
done.resolve(configArg);
});
return done.promise;
}
}
return done.promise;
};
export let run = function(configArg) {
let done = plugins.Q.defer();
let config = configArg;
plugins.beautylog.log("now starting tests");
console.log(
"--------------------------------------------------------------\n" +
"***************************" +
" TESTS: ".blue +
"***************************\n" +
"--------------------------------------------------------------"
);
istanbul(config)
.then(mocha)
.then(coverage)
.then(done.resolve);
return done.promise;
};

View File

@ -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;
}
}

View File

@ -1,7 +1,8 @@
{
"ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
"istanbul": "registry:dt/istanbul#0.4.0+20160316155526",
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
}
}

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,3 +0,0 @@
/// <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

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

File diff suppressed because it is too large Load Diff

View File

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