Compare commits
189 Commits
Author | SHA1 | Date | |
---|---|---|---|
dd9df9f5ee | |||
c109952a22 | |||
b14c79f6ef | |||
66ad3aeeb9 | |||
a6e91c6a7f | |||
f65c09c24e | |||
e8053fa9e1 | |||
759d4031d2 | |||
28e71356ff | |||
962246157c | |||
043f6e8581 | |||
e30dc5d77c | |||
e297be6fc2 | |||
659907d280 | |||
50db40d831 | |||
fbf5dce989 | |||
b6e418a431 | |||
7f69a5eaab | |||
e1f80ee888 | |||
3f261a4fa6 | |||
e75de7590e | |||
94c0663980 | |||
995161dd54 | |||
29c941044f | |||
1dc8b1aeec | |||
a0c83c8f48 | |||
b6e63664bb | |||
88b39213a6 | |||
6dad1c3d85 | |||
7d9b9b2d1d | |||
e3e6a326b5 | |||
3d59f6d393 | |||
07d752449e | |||
ea779add20 | |||
938a7bd872 | |||
45f9674550 | |||
eae983b271 | |||
871990725d | |||
d46bb18893 | |||
d8fb9747cd | |||
53209b18a9 | |||
3e3561f4bb | |||
099b513e0a | |||
cf15c428c1 | |||
3bd876a201 | |||
af62f20614 | |||
69eba08b27 | |||
6635265f4b | |||
ebdda5f969 | |||
f3a24154b4 | |||
2980b6b5f3 | |||
570046ff67 | |||
112ce2d0d6 | |||
791eaefe3c | |||
a3af90844a | |||
e389f78256 | |||
9e8fc76623 | |||
bf20ad9e61 | |||
58043d0fa2 | |||
5b0814520a | |||
848d40eeac | |||
73f5a0b055 | |||
f2a169ac7d | |||
3cdd22044e | |||
60d200135e | |||
e8238dc907 | |||
007e7539c8 | |||
e3c2c56548 | |||
f0954b19e0 | |||
48a9d19b8e | |||
7d39683972 | |||
01e9f386a6 | |||
2f4fb28b5d | |||
50b14e60c6 | |||
4753a4ff82 | |||
fe9ea47208 | |||
c8f29dc146 | |||
e7e228c900 | |||
b76cb1376d | |||
eed1a65415 | |||
040100b73f | |||
3ce49c7e97 | |||
55d7018891 | |||
d98d035902 | |||
217af24d25 | |||
11c43f59d9 | |||
14c36dd894 | |||
9f74fab2b2 | |||
8efa67a4ff | |||
f7304f59a5 | |||
070385867e | |||
e429eb8ae0 | |||
6045174edb | |||
08dcdb2c9f | |||
44aa92c83c | |||
e43541cf90 | |||
414e845b80 | |||
c18eb85ec8 | |||
3ae3598c96 | |||
26eca7aa65 | |||
48d9de65a0 | |||
db63e07fa3 | |||
be65ee65cb | |||
78bbe2d1d7 | |||
3960cd9973 | |||
0bad43d726 | |||
d5407e33dd | |||
2035045aef | |||
de0f8cfb8b | |||
fe7d2f1024 | |||
9f0343b01c | |||
04a02f6b96 | |||
cb3f343c92 | |||
6227e47037 | |||
2730ca4299 | |||
07aae64965 | |||
56841d5bb0 | |||
40301ede35 | |||
70213b04bc | |||
5160aab180 | |||
e8806e548b | |||
fcdaad540e | |||
6f33b1f5ef | |||
45418d6049 | |||
4261ee3687 | |||
9fc3606163 | |||
2436b30605 | |||
9ad59704be | |||
29f3832d63 | |||
2d82a3a037 | |||
4806f5ceff | |||
f2ef982189 | |||
5d6ead017b | |||
1c2b4e421d | |||
6cf7d2ca0b | |||
676c072631 | |||
f29c04e09c | |||
77a06a0fc4 | |||
c9792b1955 | |||
b87de178c0 | |||
0580f29d30 | |||
2c17273671 | |||
669ed2e6ab | |||
8bc73b2bf4 | |||
78e5defd7c | |||
7e540bda87 | |||
b293dfe92d | |||
a753a5db2c | |||
27f79b4425 | |||
1ada5dd5a9 | |||
a41bfd442c | |||
2917b10ffb | |||
bfc5bbbbb7 | |||
cf507a4a17 | |||
73a57ed264 | |||
39b79b679c | |||
cc053ee396 | |||
df5371187b | |||
cbda76c380 | |||
e20bcec133 | |||
3e673e04b2 | |||
2090dad540 | |||
ebe7a02ef0 | |||
3f9194f344 | |||
13c9c96cc6 | |||
3f0b2b1599 | |||
d477e492eb | |||
f39cb03fc2 | |||
f42744b927 | |||
038994e9e5 | |||
7a26721420 | |||
0dc307f082 | |||
4b2c0fe461 | |||
50fd5e83ad | |||
3e55a666b2 | |||
5d8ce3f227 | |||
de4bbaed9f | |||
7d18e92ff1 | |||
634763c03f | |||
3352165436 | |||
6c57a4703f | |||
822734e545 | |||
8dcbe98c60 | |||
2fbcb58078 | |||
362f8d5388 | |||
8fb4a60fb3 | |||
7c6b5afd5f | |||
f83eb035c2 | |||
359e844c69 |
11
.gitignore
vendored
11
.gitignore
vendored
@ -1,6 +1,13 @@
|
|||||||
.idea/
|
.idea/
|
||||||
.c9/
|
.c9/
|
||||||
node_modules/
|
node_modules/
|
||||||
test/node_modules
|
test/assets/**/node_modules/
|
||||||
|
test/assets/**/docs/
|
||||||
|
test/assets/**/typings/
|
||||||
|
test/assets/**/coverage/
|
||||||
ts/*.js
|
ts/*.js
|
||||||
ts/*.js.map
|
ts/*.js.map
|
||||||
|
ts/typings/
|
||||||
|
docs/
|
||||||
|
|
||||||
|
.DS_Store
|
@ -1,6 +1,7 @@
|
|||||||
.idea/
|
.idea/
|
||||||
support
|
support
|
||||||
compile
|
compile
|
||||||
test
|
test/
|
||||||
|
docs/
|
||||||
examples
|
examples
|
||||||
.gitignore
|
.gitignore
|
@ -1,6 +1,7 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "4.2.4"
|
- 4.3.1
|
||||||
|
- stable
|
||||||
deploy:
|
deploy:
|
||||||
provider: npm
|
provider: npm
|
||||||
email: npm@lossless.digital
|
email: npm@lossless.digital
|
||||||
@ -9,3 +10,6 @@ deploy:
|
|||||||
on:
|
on:
|
||||||
tags: true
|
tags: true
|
||||||
repo: pushrocks/npmts
|
repo: pushrocks/npmts
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
secure: kPKBMnEKoC+K5dXpl11NhuK3LSp0c0fRO60Akj3QeQBjUWnVAcF0Ht30c31y0lnJaMEzXhmUIKdR7RQnlmw5be4TYGINzY7FD3Dcv7o+HO1ZQrkpMWSu46jF6ZJer9moGjZ8e0rX8wZyB9SqsXYlwWRzqvxfOVxQfTvU3BEnJKHbhq+R5JMJ8dwLBPNTJKMWKq85KNsjo3ap0BjxdBUoRLzvrn31VOPH30BkvmLGc5YiIz5QmITll/T2wmQKYTNT2qDlEJ729B8pYa3eNlCNi89AxsLDGCmEoJAVrPsyw5g+gAyBqZ1GRULy83UJbELUq7cse3MRLMSwCAm4f0INRAuqcyiKYJ4+LHd0NwKrFQ/dQ0pvyBTbbEjNemXaakkWH7S6F03UvF+u+tiQ7C97XH0CRsseGlm36zCkAClEhtWVWA4U0Q5c6zqRAAOYOI0xquXalRKPTJe7fCYewp2eqmlp8drt8MxancyKI/ynXNoR5vGFzDTSRoPjTlaYQPmbiH4+Nd5+6Qoj94PEIqghebIPDQo3C7vWts4WGccux5b2q524UgB63hjJQA6+GQOo1q4RibouS6WScn8/tW/ZOEP+sNhDfkeiZUIjye+Q3PyzonGHefgSQ8wBbsc8LOX0cKUcEFWr14nhdQ9ZeW+hrSSF04TbM4zGJPGcKhmT2UU=
|
||||||
|
@ -1 +0,0 @@
|
|||||||
# README-dev
|
|
123
README.md
123
README.md
@ -1,7 +1,20 @@
|
|||||||
# npmts
|
# npmts
|
||||||
Write npm modules with TypeScript without hassle.
|
Write npm modules with TypeScript without hassle.
|
||||||
|
|
||||||
## How to use npmts
|
## Status
|
||||||
|
[](https://travis-ci.org/pushrocks/npmts)
|
||||||
|
[](https://ci.appveyor.com/project/philkunz/npmts)
|
||||||
|
[](https://david-dm.org/pushrocks/npmts)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/npmts/master/dependencies/npm)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/npmts)
|
||||||
|
[](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.
|
||||||
|
By default NPMTS will **bundle declaration files**. As a result npm module **code completion in editors like Visual Studio Code** works.
|
||||||
|
|
||||||
|
There is a docker image available that includes npmts to make CI a breeze:
|
||||||
|
[hosttoday/ht-docker-npmg on Dockerhub](https://hub.docker.com/r/hosttoday/ht-docker-npmg/)
|
||||||
|
|
||||||
### Install
|
### Install
|
||||||
First install npmts as dev dependency:
|
First install npmts as dev dependency:
|
||||||
@ -18,28 +31,104 @@ Then use it in package.json's script section to trigger a build:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Default behaviour
|
### Default task execution order
|
||||||
by default npmts looks for `./ts/index.ts` and `./ts/test.ts` that will compile to
|
|
||||||
`./index.js` and `./test.js`
|
|
||||||
|
|
||||||
#### Declaration files
|
1. Check config in ./npmts.json
|
||||||
**npmts** also creates an `index.d.ts` declaration file by default.
|
1. Clean up from any previous builds (old js files)
|
||||||
You can reference it in your package.json like this:
|
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.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"main": "index.js",
|
{
|
||||||
"typings": "./index.d.ts",
|
"mode":"default",
|
||||||
|
"codecov":true,
|
||||||
|
"ts":{
|
||||||
|
"./customdir/*.ts":"./"
|
||||||
|
},
|
||||||
|
"docs": {
|
||||||
|
"publish":true,
|
||||||
|
"destination":"github"
|
||||||
|
},
|
||||||
|
"tsOptions":{
|
||||||
|
"declaration":false,
|
||||||
|
"target":"ES6"
|
||||||
|
},
|
||||||
|
"typings":[
|
||||||
|
"./ts/typings.json",
|
||||||
|
"./subts1/typings.json",
|
||||||
|
"./subts2/typings.json",
|
||||||
|
"./customdir/typings.json"
|
||||||
|
],
|
||||||
|
"typingsInclude":"auto",
|
||||||
|
"cli":true
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
When requiring the module from other TypeScript files,
|
| key | default value | description |
|
||||||
the TypeScript Compiler will use the declaration file to resolve typings.
|
| --- | --- | --- |
|
||||||
|
| `"codecov"` | `true` | if true, coverage data will be uploaded to codecov when running on travis |
|
||||||
|
| `"docs"` | `{"publish":"false"}` | `{"publish":true, destination:"github"}` lets you control what happens with your module documentation |
|
||||||
|
| `"mode"` | `"default"` | "default" will do some defualt stuff, "custom" only does what you specify |
|
||||||
|
| `"tsOptions"` | `{"target":"ES5", "declaration":"true"}` | specify options for tsc |
|
||||||
|
| `"typings"` | `["./ts/typings.json"]` | allows you to specify multiple locations for typings.json to install. This is needed for modules that do not yet bundle typings |
|
||||||
|
| `"cli"` | "false" | some modules are designed to be used from cli. If set to true NPMTS will create a cli.js that wires you dist files up for cli use. |
|
||||||
|
|
||||||
|
#### Typings
|
||||||
|
**npmts** looks for `./ts/typings.json` by default and installs any defined typings to `.ts/typings/`.
|
||||||
|
|
||||||
|
> Note: You can reference the typings files in any of your TypeScript code with a
|
||||||
|
`/// <reference path="/some/path/main.d.ts">`
|
||||||
|
We are currently working on a "typingsInclude" option, that will autoload any typings during compilation.
|
||||||
|
tsconfig is NOT supported, since it would render this module useless
|
||||||
|
|
||||||
### Custom behaviour
|
#### TypeScript
|
||||||
We are currently building support for custom behaviour with a super simple config file.
|
by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
|
||||||
Check back soon.
|
`./dist/*.js` and `./test/test.js`
|
||||||
|
|
||||||
## Readme for Devs
|
Use commonjs module system for wiring up files.
|
||||||
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.
|
#### Declaration files
|
||||||
|
**npmts** also creates an `./dist/index.d.ts` declaration file by default.
|
||||||
|
You can reference it in your package.json like this.
|
||||||
|
|
||||||
|
```json
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"typings": ".dist/index.d.ts",
|
||||||
|
```
|
||||||
|
|
||||||
|
This is in line with the latest TypeScript best practices.
|
||||||
|
You can then import plugins via the TypeScript `import` Syntax
|
||||||
|
and tsc will pick up the declaration file automatically.
|
||||||
|
|
||||||
|
> Note: If you don't want declaration files, set tsOptions.declaration to false in npmts.json
|
||||||
|
|
||||||
|
#### 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.
|
||||||
|
|
||||||
|
## Example Usage in modules:
|
||||||
|
* [gulp-typings](https://www.npmjs.com/package/gulp-typings)
|
||||||
|
* [gulp-browser](https://www.npmjs.com/package/gulp-typings)
|
||||||
|
|
||||||
|
> We will add more options over time.
|
||||||
|
|
||||||
|
## About the authors:
|
||||||
|
[](https://lossless.com/)
|
||||||
|
|
||||||
|
[](https://paypal.me/lossless)
|
||||||
|
10
appveyor.yml
Normal file
10
appveyor.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
environment:
|
||||||
|
nodejs_version: "4"
|
||||||
|
install:
|
||||||
|
- ps: Install-Product node $env:nodejs_version
|
||||||
|
- npm install
|
||||||
|
test_script:
|
||||||
|
- node --version
|
||||||
|
- npm --version
|
||||||
|
- npm test
|
||||||
|
build: off
|
2
assets/cli.js
Normal file
2
assets/cli.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var index = require("./index.js");
|
1
assets/node-shebang.js
Normal file
1
assets/node-shebang.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
#!/usr/bin/env node
|
@ -4,31 +4,45 @@ var plugins = {
|
|||||||
gulp: require("gulp"),
|
gulp: require("gulp"),
|
||||||
g:{
|
g:{
|
||||||
typescript: require("gulp-typescript"),
|
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 the mojo.io gulp tasks');
|
plugins.beautylog.log('now compiling NPMTS');
|
||||||
|
|
||||||
plugins.gulp.task('indexTS', function() {
|
plugins.gulp.task("typings",function(){
|
||||||
var tsResult = plugins.gulp.src('../ts/index.ts')
|
var stream = plugins.gulp.src(plugins.path.join(paths.packageBase,"ts/typings.json"))
|
||||||
.pipe(plugins.g.typescript({
|
.pipe(plugins.g.typings());
|
||||||
out:"index.js",
|
return stream;
|
||||||
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('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');
|
plugins.beautylog.success('Typescript compiled');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
2
dist/cli.js
vendored
Normal file
2
dist/cli.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var index = require("./index.js");
|
14
dist/index.js
vendored
Normal file
14
dist/index.js
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
var early = require("early");
|
||||||
|
early.start("NPMTS");
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
early.stop();
|
||||||
|
plugins.beautylog.figletSync("NPMTS");
|
||||||
|
try {
|
||||||
|
npmts_promisechain_1.promisechain();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
19
dist/npmts.assets.js
vendored
Normal file
19
dist/npmts.assets.js
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
npmts_promisechain_1.npmtsOra.text("now looking at " + "required assets".yellow);
|
||||||
|
if (config.cli == true) {
|
||||||
|
plugins.smartfile.fsaction.copy(plugins.path.join(paths.npmtsAssetsDir, "cli.js"), paths.distDir);
|
||||||
|
plugins.beautylog.ok("installed CLI assets!");
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
};
|
24
dist/npmts.clean.js
vendored
Normal file
24
dist/npmts.clean.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
var removeDist = function () {
|
||||||
|
npmts_promisechain_1.npmtsOra.text("cleaning " + "dist".yellow + " folder");
|
||||||
|
return plugins.smartfile.fsaction.remove(paths.distDir);
|
||||||
|
};
|
||||||
|
var removeTypings = function () {
|
||||||
|
npmts_promisechain_1.npmtsOra.text("cleaning " + "typings".yellow + " folder");
|
||||||
|
return plugins.smartfile.fsaction.remove(paths.typingsDir);
|
||||||
|
};
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
npmts_promisechain_1.npmtsOra.text("cleaning up from previous builds...");
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
removeDist()
|
||||||
|
.then(removeTypings)
|
||||||
|
.then(function () {
|
||||||
|
plugins.beautylog.ok("Cleaned up from previous builds!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
1
dist/npmts.cli.js
vendored
Normal file
1
dist/npmts.cli.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/// <reference path="./typings/index.d.ts" />
|
16
dist/npmts.compile.helpers.js
vendored
Normal file
16
dist/npmts.compile.helpers.js
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"use strict";
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var outputPathIsDir = function (configArg, keyArg) {
|
||||||
|
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, configArg.ts[keyArg]));
|
||||||
|
};
|
||||||
|
exports.checkOutputPath = function (configArg, keyArg) {
|
||||||
|
if (!outputPathIsDir(configArg, keyArg)) {
|
||||||
|
plugins.beautylog.warn("Skipping " + keyArg + " because " + configArg.ts[keyArg] + " it is no directory!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
};
|
79
dist/npmts.compile.js
vendored
Normal file
79
dist/npmts.compile.js
vendored
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var helpers = require("./npmts.compile.helpers");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
/**
|
||||||
|
* handles definition to make them fit for modular use
|
||||||
|
*/
|
||||||
|
var definitionHandler = function (configArg) {
|
||||||
|
npmts_promisechain_1.npmtsOra.text("now making declaration files ready");
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var configTsLenght = Object.keys(configArg.ts).length;
|
||||||
|
if (configTsLenght == 0) {
|
||||||
|
plugins.beautylog.warn("No declaration files found... Are you sure you don't want them?");
|
||||||
|
done.resolve(configArg); //if there are no definition files, resolve...
|
||||||
|
}
|
||||||
|
var localCounter = 0;
|
||||||
|
for (var key in configArg.ts) {
|
||||||
|
var distPath = configArg.ts[key];
|
||||||
|
var stream = plugins.gulp.src(plugins.path.join(distPath, "**/*.d.ts"))
|
||||||
|
.pipe(plugins.g.replace(plugins.smartstring.typescript.regexReferencePath, ""))
|
||||||
|
.pipe(plugins.gulp.dest(distPath))
|
||||||
|
.pipe(plugins.g.gFunction(function () {
|
||||||
|
localCounter++;
|
||||||
|
if (localCounter == configTsLenght) {
|
||||||
|
plugins.beautylog.ok("made declaration files ready!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
}, "atEnd"));
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
npmts_promisechain_1.npmtsOra.text("now compiling " + "TypeScript".yellow);
|
||||||
|
var moduleStream = plugins.merge2({ end: false });
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- compile TypeScript --------------------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
var tsOptionsDefault = {
|
||||||
|
declaration: true,
|
||||||
|
target: "ES5",
|
||||||
|
module: "commonjs"
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* merges default ts options with those found in npmts.json
|
||||||
|
*/
|
||||||
|
var tsOptions = function (keyArg) {
|
||||||
|
return plugins.lodashObject.assign(tsOptionsDefault, config.tsOptions);
|
||||||
|
};
|
||||||
|
for (var keyArg in config.ts) {
|
||||||
|
if (helpers.checkOutputPath(config, keyArg)) {
|
||||||
|
var tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"])
|
||||||
|
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
||||||
|
.pipe(plugins.g.typescript(tsOptions(keyArg)));
|
||||||
|
var jsStream = tsStream.js
|
||||||
|
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||||
|
.pipe(plugins.gulp.dest(config.ts[keyArg]));
|
||||||
|
var declarationStream = tsStream.dts
|
||||||
|
.pipe(plugins.gulp.dest(config.ts[keyArg]));
|
||||||
|
moduleStream.add(tsStream, jsStream, declarationStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
moduleStream.on("queueDrain", function () {
|
||||||
|
moduleStream.on("finish", function () {
|
||||||
|
plugins.beautylog.ok("compiled TypeScript!");
|
||||||
|
definitionHandler(config)
|
||||||
|
.then(function () {
|
||||||
|
done.resolve(config);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
moduleStream.end();
|
||||||
|
});
|
||||||
|
/*==================== END TS Compilation =====================*/
|
||||||
|
return done.promise;
|
||||||
|
};
|
31
dist/npmts.configfile.js
vendored
Normal file
31
dist/npmts.configfile.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.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;
|
||||||
|
};
|
21
dist/npmts.install.js
vendored
Normal file
21
dist/npmts.install.js
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var config = configArg;
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- install typings ---------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
npmts_promisechain_1.npmtsOra.text("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 installed!");
|
||||||
|
done.resolve(config);
|
||||||
|
}, "atEnd"));
|
||||||
|
return done.promise;
|
||||||
|
};
|
56
dist/npmts.jsdoc.js
vendored
Normal file
56
dist/npmts.jsdoc.js
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
var genJsdoc = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
npmts_promisechain_1.npmtsOra.text("now generating " + "JsDoc documentation".yellow);
|
||||||
|
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;
|
||||||
|
};
|
51
dist/npmts.options.js
vendored
Normal file
51
dist/npmts.options.js
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
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;
|
||||||
|
npmts_promisechain_1.npmtsOra.text("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"];
|
||||||
|
}
|
||||||
|
//check if config.tsOptions is available
|
||||||
|
config.tsOptions ? void (0) : config.tsOptions = {};
|
||||||
|
// 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;
|
||||||
|
};
|
15
dist/npmts.paths.js
vendored
Normal file
15
dist/npmts.paths.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
exports.cwd = plugins.smartcli.get.cwd().path;
|
||||||
|
//Directories
|
||||||
|
exports.tsDir = plugins.path.join(exports.cwd, "ts/");
|
||||||
|
exports.distDir = plugins.path.join(exports.cwd, "dist/");
|
||||||
|
exports.docsDir = plugins.path.join(exports.cwd, "docs/");
|
||||||
|
exports.testDir = plugins.path.join(exports.cwd, "test/");
|
||||||
|
exports.typingsDir = plugins.path.join(exports.cwd, "ts/typings/");
|
||||||
|
exports.coverageDir = plugins.path.join(exports.cwd, "coverage/");
|
||||||
|
exports.npmtsAssetsDir = plugins.path.join(__dirname, "../assets/");
|
||||||
|
//Files
|
||||||
|
exports.indexTS = plugins.path.join(exports.cwd, "ts/index.ts");
|
||||||
|
exports.testTS = plugins.path.join(exports.cwd, "ts/test.ts");
|
30
dist/npmts.plugins.js
vendored
Normal file
30
dist/npmts.plugins.js
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.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"),
|
||||||
|
replace: require("gulp-replace"),
|
||||||
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
|
typescript: require("gulp-typescript"),
|
||||||
|
typings: require("gulp-typings")
|
||||||
|
};
|
||||||
|
exports.lodashObject = require('lodash/fp/object');
|
||||||
|
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.smartstring = require("smartstring");
|
||||||
|
exports.sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing
|
51
dist/npmts.promisechain.js
vendored
Normal file
51
dist/npmts.promisechain.js
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
exports.npmtsOra = new plugins.beautylog.Ora("setting up TaskChain", "cyan");
|
||||||
|
exports.npmtsOra.start();
|
||||||
|
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.promisechain = function () {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
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!");
|
||||||
|
}
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
15
dist/npmts.publish.js
vendored
Normal file
15
dist/npmts.publish.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.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;
|
||||||
|
};
|
79
dist/npmts.tests.js
vendored
Normal file
79
dist/npmts.tests.js
vendored
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
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) {
|
||||||
|
npmts_promisechain_1.npmtsOra.text("Instrumentalizing transpiled JS...");
|
||||||
|
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 () {
|
||||||
|
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
}, "atEnd"));
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
var mocha = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
npmts_promisechain_1.npmtsOra.end(); // end npmtsOra for tests.
|
||||||
|
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;
|
||||||
|
npmts_promisechain_1.npmtsOra.text("now starting tests");
|
||||||
|
plugins.beautylog.log("-------------------------------------------------------\n" +
|
||||||
|
"*************************** TESTS: ***************************\n" +
|
||||||
|
"--------------------------------------------------------------");
|
||||||
|
istanbul(config)
|
||||||
|
.then(mocha)
|
||||||
|
.then(coverage)
|
||||||
|
.then(done.resolve);
|
||||||
|
return done.promise;
|
||||||
|
};
|
38
index.d.ts
vendored
38
index.d.ts
vendored
@ -1,38 +0,0 @@
|
|||||||
/// <reference path="../ts/typings/tsd.d.ts" />
|
|
||||||
declare module NpmtsPlugins {
|
|
||||||
var init: () => {
|
|
||||||
beautylog: any;
|
|
||||||
gulp: any;
|
|
||||||
g: {
|
|
||||||
if: any;
|
|
||||||
insert: any;
|
|
||||||
sequence: any;
|
|
||||||
tsd: any;
|
|
||||||
typescript: any;
|
|
||||||
};
|
|
||||||
mergeStream: any;
|
|
||||||
path: any;
|
|
||||||
smartcli: any;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
declare module NpmtsPaths {
|
|
||||||
var init: () => any;
|
|
||||||
}
|
|
||||||
declare module NpmtsDefault {
|
|
||||||
var init: () => void;
|
|
||||||
}
|
|
||||||
declare var plugins: {
|
|
||||||
beautylog: any;
|
|
||||||
gulp: any;
|
|
||||||
g: {
|
|
||||||
if: any;
|
|
||||||
insert: any;
|
|
||||||
sequence: any;
|
|
||||||
tsd: any;
|
|
||||||
typescript: any;
|
|
||||||
};
|
|
||||||
mergeStream: any;
|
|
||||||
path: any;
|
|
||||||
smartcli: any;
|
|
||||||
};
|
|
||||||
declare var paths: any;
|
|
96
index.js
96
index.js
@ -1,96 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsPlugins;
|
|
||||||
(function (NpmtsPlugins) {
|
|
||||||
NpmtsPlugins.init = function () {
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
gulp: require("gulp"),
|
|
||||||
g: {
|
|
||||||
if: require("gulp-if"),
|
|
||||||
insert: require("gulp-insert"),
|
|
||||||
sequence: require("gulp-sequence"),
|
|
||||||
tsd: require("gulp-tsd"),
|
|
||||||
typescript: require("gulp-typescript")
|
|
||||||
},
|
|
||||||
mergeStream: require("merge2"),
|
|
||||||
path: require("path"),
|
|
||||||
smartcli: require("smartcli")
|
|
||||||
};
|
|
||||||
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.tsd = plugins.path.join(paths.cwd, "ts/tsd.json");
|
|
||||||
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
|
||||||
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
|
|
||||||
return paths;
|
|
||||||
};
|
|
||||||
})(NpmtsPaths || (NpmtsPaths = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsDefault;
|
|
||||||
(function (NpmtsDefault) {
|
|
||||||
NpmtsDefault.init = function () {
|
|
||||||
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)
|
|
||||||
.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);
|
|
||||||
plugins.gulp.src(paths.testTS)
|
|
||||||
.pipe(plugins.g.typescript({
|
|
||||||
out: "test.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd));
|
|
||||||
});
|
|
||||||
plugins.gulp.task("defaultCleanup", function (cb) {
|
|
||||||
plugins.beautylog.success("TypeScript for this module compiled successfully.");
|
|
||||||
cb();
|
|
||||||
});
|
|
||||||
plugins.gulp.task("default", function (cb) {
|
|
||||||
plugins.g.sequence("defaultTsd", "defaultIndexTS", "defaultTestTS", "defaultCleanup", cb);
|
|
||||||
});
|
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
|
||||||
};
|
|
||||||
})(NpmtsDefault || (NpmtsDefault = {}));
|
|
||||||
/// <reference path="./typings/tsd.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.custom.ts" />
|
|
||||||
/// <reference path="./npmts.default.ts" />
|
|
||||||
var plugins = NpmtsPlugins.init();
|
|
||||||
var paths = NpmtsPaths.init();
|
|
||||||
NpmtsDefault.init();
|
|
52
package.json
52
package.json
@ -1,16 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "1.0.11",
|
"version": "5.1.11",
|
||||||
"description": "write npm modules with TypeScript",
|
"description": "write npm modules with TypeScript",
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "./index.d.ts",
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"npmts": "./index.js"
|
"npmts": "dist/cli.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(cd compile && node compile.js)",
|
"test": "(npm run compile && npm run check)",
|
||||||
"testm": "(npm test) && (cd test/ && node ../index.js)",
|
"check": "(cd ./test/assets && node ../../dist/index.js)",
|
||||||
"release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)"
|
"compile": "(cd compile && node compile.js)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -27,13 +26,34 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/npmts#readme",
|
"homepage": "https://github.com/pushrocks/npmts#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "2.0.2",
|
"beautylog": "5.0.5",
|
||||||
"gulp": "3.9.0",
|
"early": "^1.0.7",
|
||||||
"gulp-insert": "0.5.0",
|
"fs-extra": "^0.30.0",
|
||||||
"gulp-sequence": "^0.4.4",
|
"gulp": "3.9.1",
|
||||||
"gulp-tsd": "^0.1.0",
|
"gulp-codecov": "^2.0.1",
|
||||||
"gulp-typescript": "2.10.0",
|
"gulp-concat": "^2.6.0",
|
||||||
"merge2": "0.3.6",
|
"gulp-function": "^1.3.1",
|
||||||
"smartcli": "0.0.11"
|
"gulp-if": "^2.0.1",
|
||||||
}
|
"gulp-istanbul": "^0.10.4",
|
||||||
|
"gulp-jsdoc3": "^0.2.1",
|
||||||
|
"gulp-mocha": "^2.2.0",
|
||||||
|
"gulp-replace": "^0.5.4",
|
||||||
|
"gulp-sourcemaps": "^2.0.0-alpha",
|
||||||
|
"gulp-typescript": "2.13.4",
|
||||||
|
"gulp-typings": "2.0.0",
|
||||||
|
"lodash": "^4.12.0",
|
||||||
|
"merge2": "1.0.2",
|
||||||
|
"projectinfo": "1.0.1",
|
||||||
|
"q": "^1.4.1",
|
||||||
|
"shelljs": "^0.7.0",
|
||||||
|
"smartci": "0.0.1",
|
||||||
|
"smartcli": "0.0.11",
|
||||||
|
"smartcov": "0.0.6",
|
||||||
|
"smartenv": "1.2.5",
|
||||||
|
"smartfile": "3.0.7",
|
||||||
|
"smartpath": "3.2.1",
|
||||||
|
"smartstring": "^1.0.3",
|
||||||
|
"source-map-support": "^0.4.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {}
|
||||||
}
|
}
|
||||||
|
3
test/assets/custom.js
Normal file
3
test/assets/custom.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
var hello = "hello";
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImN1c3RvbS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxJQUFJLEtBQUssR0FBRyxPQUFPLENBQUMiLCJmaWxlIjoiY3VzdG9tLmpzIiwic291cmNlc0NvbnRlbnQiOlsidmFyIGhlbGxvID0gXCJoZWxsb1wiOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
2
test/assets/customdir/custom.js
Normal file
2
test/assets/customdir/custom.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var hello = "hello";
|
||||||
|
//# sourceMappingURL=custom.js.map
|
1
test/assets/customdir/custom.js.map
Normal file
1
test/assets/customdir/custom.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"custom.js","sourceRoot":"","sources":["custom.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,OAAO,CAAC"}
|
1
test/assets/customdir/custom.ts
Normal file
1
test/assets/customdir/custom.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
var hello = "hello";
|
2
test/assets/customdir/tsfile1.js
Normal file
2
test/assets/customdir/tsfile1.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var something = "something";
|
||||||
|
//# sourceMappingURL=tsfile1.js.map
|
1
test/assets/customdir/tsfile1.js.map
Normal file
1
test/assets/customdir/tsfile1.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"tsfile1.js","sourceRoot":"","sources":["tsfile1.ts"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,WAAW,CAAC"}
|
1
test/assets/customdir/tsfile1.ts
Normal file
1
test/assets/customdir/tsfile1.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
var something = "something";
|
7
test/assets/customdir/typings.json
Normal file
7
test/assets/customdir/typings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||||
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
|
}
|
||||||
|
}
|
3
test/assets/dist/index.d.ts
vendored
Normal file
3
test/assets/dist/index.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
declare let testplugin: {
|
||||||
|
logSomething: () => void;
|
||||||
|
};
|
9
test/assets/dist/index.js
vendored
Normal file
9
test/assets/dist/index.js
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
var testplugin = {
|
||||||
|
logSomething: function () {
|
||||||
|
console.log("only function executed");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
module.exports = testplugin;
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDZDQUE2QztBQUM3QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9pbmRleC5kLnRzXCIgLz5cclxubGV0IHRlc3RwbHVnaW4gPSB7XHJcbiAgICBsb2dTb21ldGhpbmc6IGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgY29uc29sZS5sb2coXCJvbmx5IGZ1bmN0aW9uIGV4ZWN1dGVkXCIpO1xyXG4gICAgfVxyXG59O1xyXG5tb2R1bGUuZXhwb3J0cyA9IHRlc3RwbHVnaW47Il19
|
20
test/assets/npmts.json
Normal file
20
test/assets/npmts.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"mode":"default",
|
||||||
|
"ts":{
|
||||||
|
"./customdir/*.ts":"./"
|
||||||
|
},
|
||||||
|
"tsOptions":{
|
||||||
|
"target":"ES5"
|
||||||
|
},
|
||||||
|
"typings":[
|
||||||
|
"./ts/typings.json",
|
||||||
|
"./subts1/typings.json",
|
||||||
|
"./subts2/typings.json",
|
||||||
|
"./customdir/typings.json"
|
||||||
|
],
|
||||||
|
"codecov":true,
|
||||||
|
"docs": {
|
||||||
|
"publish":true
|
||||||
|
},
|
||||||
|
"cli":true
|
||||||
|
}
|
16
test/assets/package.json
Normal file
16
test/assets/package.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"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": {}
|
||||||
|
}
|
7
test/assets/subts1/typings.json
Normal file
7
test/assets/subts1/typings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||||
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
|
}
|
||||||
|
}
|
BIN
test/assets/test/.DS_Store
vendored
Normal file
BIN
test/assets/test/.DS_Store
vendored
Normal file
Binary file not shown.
1
test/assets/test/test.d.ts
vendored
Normal file
1
test/assets/test/test.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
declare var testplugin: any;
|
11
test/assets/test/test.js
Normal file
11
test/assets/test/test.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/// <reference path="../ts/typings/index.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;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsaURBQWlEO0FBQ2pELElBQUksVUFBVSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzdDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixFQUFFLENBQUMsc0JBQXNCLEVBQUM7WUFDdEIsVUFBVSxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQzdCLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvaW5kZXguZC50c1wiIC8+XHJcbnZhciB0ZXN0cGx1Z2luID0gcmVxdWlyZShcIi4uL2Rpc3QvaW5kZXguanNcIik7XHJcbmRlc2NyaWJlKFwidGVzdHBsdWdpbnNcIixmdW5jdGlvbigpe1xyXG4gICAgZGVzY3JpYmUoXCIubG9nU29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcclxuICAgICAgICBpdChcInNob3VsZCBsb2cgc29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcclxuICAgICAgICAgICAgdGVzdHBsdWdpbi5sb2dTb21ldGhpbmcoKVxyXG4gICAgICAgIH0pO1xyXG4gICAgfSk7XHJcbn0pOyJdfQ==
|
1
test/assets/test/test.js.map
Normal file
1
test/assets/test/test.js.map
Normal 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
9
test/assets/test/test.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/// <reference path="../ts/typings/index.d.ts" />
|
||||||
|
var testplugin = require("../dist/index.js");
|
||||||
|
describe("testplugins",function(){
|
||||||
|
describe(".logSomething",function(){
|
||||||
|
it("should log something",function(){
|
||||||
|
testplugin.logSomething()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
8
test/assets/test/typings.json
Normal file
8
test/assets/test/typings.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
7
test/assets/ts/index.ts
Normal file
7
test/assets/ts/index.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
let testplugin = {
|
||||||
|
logSomething: function(){
|
||||||
|
console.log("only function executed");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
module.exports = testplugin;
|
8
test/assets/ts/typings.json
Normal file
8
test/assets/ts/typings.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"globalDependencies": {
|
||||||
|
"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
3
test/assets/tsfile1.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
var something = "something";
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRzZmlsZTEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsSUFBSSxTQUFTLEdBQUcsV0FBVyxDQUFDIiwiZmlsZSI6InRzZmlsZTEuanMiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgc29tZXRoaW5nID0gXCJzb21ldGhpbmdcIjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
0
test/index.d.ts
vendored
0
test/index.d.ts
vendored
@ -1,5 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
console.log("test");
|
|
||||||
}());
|
|
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "test",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "(npmts)"
|
|
||||||
},
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"npmts": "*"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
(function () {
|
|
||||||
console.log("test");
|
|
||||||
}());
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"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"}
|
|
@ -1,3 +0,0 @@
|
|||||||
(function(){
|
|
||||||
console.log("test")
|
|
||||||
}());
|
|
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
123
test/ts/typings/colors/colors.d.ts
vendored
123
test/ts/typings/colors/colors.d.ts
vendored
@ -1,123 +0,0 @@
|
|||||||
// 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;
|
|
||||||
}
|
|
2090
test/ts/typings/node/node.d.ts
vendored
2090
test/ts/typings/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
3
test/ts/typings/tsd.d.ts
vendored
3
test/ts/typings/tsd.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
/// <reference path="colors/colors.d.ts" />
|
|
||||||
/// <reference path="node/node.d.ts" />
|
|
||||||
/// <reference path="vinyl/vinyl.d.ts" />
|
|
109
test/ts/typings/vinyl/vinyl.d.ts
vendored
109
test/ts/typings/vinyl/vinyl.d.ts
vendored
@ -1,109 +0,0 @@
|
|||||||
// 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' {
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
25
ts/index.ts
25
ts/index.ts
@ -1,11 +1,16 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/index.d.ts" />
|
||||||
/// <reference path="./npmts.plugins.ts" />
|
import * as early from "early";
|
||||||
/// <reference path="./npmts.cli.ts" />
|
early.start("NPMTS");
|
||||||
/// <reference path="./npmts.paths.ts" />
|
import * as plugins from "./npmts.plugins"
|
||||||
/// <reference path="./npmts.options.ts" />
|
import {promisechain} from "./npmts.promisechain";
|
||||||
/// <reference path="./npmts.custom.ts" />
|
early.stop();
|
||||||
/// <reference path="./npmts.default.ts" />
|
|
||||||
|
plugins.beautylog.figletSync("NPMTS");
|
||||||
|
|
||||||
|
try {
|
||||||
|
promisechain();
|
||||||
|
}
|
||||||
|
catch(err){
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
|
||||||
var plugins = NpmtsPlugins.init();
|
|
||||||
var paths = NpmtsPaths.init();
|
|
||||||
NpmtsDefault.init();
|
|
||||||
|
18
ts/npmts.assets.ts
Normal file
18
ts/npmts.assets.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
|
|
||||||
|
export var run = function(configArg){
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let config = configArg;
|
||||||
|
npmtsOra.text("now looking at " + "required assets".yellow);
|
||||||
|
if(config.cli == true){
|
||||||
|
plugins.smartfile.fsaction.copy(plugins.path.join(paths.npmtsAssetsDir,"cli.js"),paths.distDir);
|
||||||
|
plugins.beautylog.ok("installed CLI assets!");
|
||||||
|
done.resolve(config);
|
||||||
|
} else {
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
};
|
26
ts/npmts.clean.ts
Normal file
26
ts/npmts.clean.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
|
|
||||||
|
let removeDist = function(){
|
||||||
|
npmtsOra.text("cleaning " + "dist".yellow + " folder");
|
||||||
|
return plugins.smartfile.fsaction.remove(paths.distDir);
|
||||||
|
};
|
||||||
|
|
||||||
|
let removeTypings = function(){
|
||||||
|
npmtsOra.text("cleaning " + "typings".yellow + " folder");
|
||||||
|
return plugins.smartfile.fsaction.remove(paths.typingsDir);
|
||||||
|
};
|
||||||
|
|
||||||
|
export let run = function(configArg){
|
||||||
|
npmtsOra.text("cleaning up from previous builds...");
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
removeDist()
|
||||||
|
.then(removeTypings)
|
||||||
|
.then(function(){
|
||||||
|
plugins.beautylog.ok("Cleaned up from previous builds!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
@ -1 +1 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/index.d.ts" />
|
15
ts/npmts.compile.helpers.ts
Normal file
15
ts/npmts.compile.helpers.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
|
||||||
|
let outputPathIsDir = function (configArg,keyArg) {
|
||||||
|
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, configArg.ts[keyArg]));
|
||||||
|
};
|
||||||
|
|
||||||
|
export let checkOutputPath = function(configArg,keyArg){
|
||||||
|
if(!outputPathIsDir(configArg,keyArg)) {
|
||||||
|
plugins.beautylog.warn("Skipping " + keyArg + " because " + configArg.ts[keyArg] + " it is no directory!")
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
90
ts/npmts.compile.ts
Normal file
90
ts/npmts.compile.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
import helpers = require("./npmts.compile.helpers");
|
||||||
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handles definition to make them fit for modular use
|
||||||
|
*/
|
||||||
|
let definitionHandler = function(configArg){
|
||||||
|
npmtsOra.text("now making declaration files ready");
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let configTsLenght = Object.keys(configArg.ts).length;
|
||||||
|
if(configTsLenght == 0) {
|
||||||
|
plugins.beautylog.warn("No declaration files found... Are you sure you don't want them?");
|
||||||
|
done.resolve(configArg); //if there are no definition files, resolve...
|
||||||
|
}
|
||||||
|
let localCounter = 0;
|
||||||
|
for (let key in configArg.ts){
|
||||||
|
let distPath = configArg.ts[key];
|
||||||
|
let stream = plugins.gulp.src(plugins.path.join(distPath,"**/*.d.ts"))
|
||||||
|
.pipe(plugins.g.replace(plugins.smartstring.typescript.regexReferencePath,""))
|
||||||
|
.pipe(plugins.gulp.dest(distPath))
|
||||||
|
.pipe(plugins.g.gFunction(function(){
|
||||||
|
localCounter++
|
||||||
|
if(localCounter == configTsLenght){
|
||||||
|
plugins.beautylog.ok("made declaration files ready!");
|
||||||
|
done.resolve(configArg)
|
||||||
|
};
|
||||||
|
},"atEnd"));
|
||||||
|
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export let run = function (configArg) {
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let config = configArg;
|
||||||
|
npmtsOra.text("now compiling " + "TypeScript".yellow);
|
||||||
|
let moduleStream = plugins.merge2({ end: false });
|
||||||
|
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- compile TypeScript --------------------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
|
||||||
|
let tsOptionsDefault = {
|
||||||
|
declaration: true,
|
||||||
|
target: "ES5",
|
||||||
|
module: "commonjs"
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* merges default ts options with those found in npmts.json
|
||||||
|
*/
|
||||||
|
let tsOptions = function (keyArg:string) {
|
||||||
|
return plugins.lodashObject.assign(tsOptionsDefault, config.tsOptions)
|
||||||
|
};
|
||||||
|
|
||||||
|
for (let keyArg in config.ts) {
|
||||||
|
if (helpers.checkOutputPath(config,keyArg)) {
|
||||||
|
let tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"])
|
||||||
|
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
||||||
|
.pipe(plugins.g.typescript(tsOptions(keyArg)));
|
||||||
|
|
||||||
|
let jsStream = tsStream.js
|
||||||
|
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||||
|
.pipe(plugins.gulp.dest(config.ts[keyArg]));
|
||||||
|
let declarationStream = tsStream.dts
|
||||||
|
.pipe(plugins.gulp.dest(config.ts[keyArg]));
|
||||||
|
moduleStream.add(tsStream,jsStream,declarationStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
moduleStream.on("queueDrain", function () {
|
||||||
|
moduleStream.on("finish", function () {
|
||||||
|
plugins.beautylog.ok("compiled TypeScript!");
|
||||||
|
definitionHandler(config)
|
||||||
|
.then(function(){
|
||||||
|
done.resolve(config);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
moduleStream.end();
|
||||||
|
});
|
||||||
|
/*==================== END TS Compilation =====================*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return done.promise;
|
||||||
|
};
|
27
ts/npmts.configfile.ts
Normal file
27
ts/npmts.configfile.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/// <reference path="./typings/index.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;
|
||||||
|
};
|
@ -1 +0,0 @@
|
|||||||
/// <reference path="./index.ts" />
|
|
@ -1,56 +0,0 @@
|
|||||||
/// <reference path="./index.ts" />
|
|
||||||
|
|
||||||
module NpmtsDefault {
|
|
||||||
export var init = function() {
|
|
||||||
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)
|
|
||||||
.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);
|
|
||||||
plugins.gulp.src(paths.testTS)
|
|
||||||
.pipe(plugins.g.typescript({
|
|
||||||
out: "test.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd))
|
|
||||||
});
|
|
||||||
|
|
||||||
plugins.gulp.task("defaultCleanup",function(cb){
|
|
||||||
plugins.beautylog.success("TypeScript for this module compiled successfully.");
|
|
||||||
cb();
|
|
||||||
});
|
|
||||||
|
|
||||||
plugins.gulp.task("default",function(cb){
|
|
||||||
plugins.g.sequence("defaultTsd","defaultIndexTS","defaultTestTS","defaultCleanup",cb);
|
|
||||||
});
|
|
||||||
|
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
|
||||||
}
|
|
||||||
}
|
|
21
ts/npmts.install.ts
Normal file
21
ts/npmts.install.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
|
|
||||||
|
export var run = function(configArg){
|
||||||
|
var config = configArg;
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- install typings ---------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
npmtsOra.text("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 installed!");
|
||||||
|
done.resolve(config);
|
||||||
|
},"atEnd"));
|
||||||
|
return done.promise;
|
||||||
|
};
|
65
ts/npmts.jsdoc.ts
Normal file
65
ts/npmts.jsdoc.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
|
|
||||||
|
let genJsdoc = function(configArg){
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
npmtsOra.text("now generating " + "JsDoc documentation".yellow);
|
||||||
|
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;
|
||||||
|
};
|
@ -0,0 +1,61 @@
|
|||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
npmtsOra.text("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"];
|
||||||
|
}
|
||||||
|
|
||||||
|
//check if config.tsOptions is available
|
||||||
|
config.tsOptions ? void(0) : config.tsOptions = {};
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
};
|
@ -1,11 +1,18 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/index.d.ts" />
|
||||||
module NpmtsPaths {
|
import plugins = require("./npmts.plugins");
|
||||||
export var init = function() {
|
|
||||||
var paths:any = {};
|
export let cwd = plugins.smartcli.get.cwd().path;
|
||||||
paths.cwd = plugins.smartcli.get.cwd().path;
|
|
||||||
paths.tsd = plugins.path.join(paths.cwd,"ts/tsd.json");
|
//Directories
|
||||||
paths.indexTS = plugins.path.join(paths.cwd,"ts/index.ts");
|
export let tsDir = plugins.path.join(cwd,"ts/");
|
||||||
paths.testTS = plugins.path.join(paths.cwd,"ts/test.ts");
|
export let distDir = plugins.path.join(cwd,"dist/");
|
||||||
return paths;
|
export let docsDir = plugins.path.join(cwd,"docs/");
|
||||||
}
|
export let testDir = plugins.path.join(cwd,"test/");
|
||||||
}
|
export let typingsDir = plugins.path.join(cwd,"ts/typings/");
|
||||||
|
export let coverageDir = plugins.path.join(cwd,"coverage/");
|
||||||
|
|
||||||
|
export let npmtsAssetsDir = plugins.path.join(__dirname,"../assets/");
|
||||||
|
|
||||||
|
//Files
|
||||||
|
export let indexTS = plugins.path.join(cwd,"ts/index.ts");
|
||||||
|
export let testTS = plugins.path.join(cwd,"ts/test.ts");
|
||||||
|
@ -1,21 +1,30 @@
|
|||||||
/// <reference path="./index.ts" />
|
/// <reference path="./typings/index.d.ts" />
|
||||||
module NpmtsPlugins {
|
export import beautylog = require("beautylog");
|
||||||
export var init = function() {
|
export let fs = require("fs-extra");
|
||||||
var plugins = {
|
export let gulp = require("gulp");
|
||||||
beautylog: require("beautylog"),
|
export let g = {
|
||||||
gulp: require("gulp"),
|
codecov: require("gulp-codecov"),
|
||||||
g: {
|
gFunction: require("gulp-function"),
|
||||||
if: require("gulp-if"),
|
istanbul: require("gulp-istanbul"),
|
||||||
insert: require("gulp-insert"),
|
jsdoc3: require("gulp-jsdoc3"),
|
||||||
sequence: require("gulp-sequence"),
|
mocha: require("gulp-mocha"),
|
||||||
tsd: require("gulp-tsd"),
|
replace: require("gulp-replace"),
|
||||||
typescript: require("gulp-typescript")
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
|
typescript: require("gulp-typescript"),
|
||||||
|
typings: require("gulp-typings")
|
||||||
|
|
||||||
},
|
};
|
||||||
mergeStream: require("merge2"),
|
export let lodashObject = require('lodash/fp/object');
|
||||||
path: require("path"),
|
export let merge2 = require("merge2");
|
||||||
smartcli: require("smartcli")
|
export let projectinfo = require("projectinfo");
|
||||||
};
|
export let path = require("path");
|
||||||
return plugins;
|
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 import smartpath = require("smartpath");
|
||||||
|
export import smartstring = require("smartstring");
|
||||||
|
export let sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing
|
52
ts/npmts.promisechain.ts
Normal file
52
ts/npmts.promisechain.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
|
||||||
|
export let npmtsOra = new plugins.beautylog.Ora("setting up TaskChain","cyan");
|
||||||
|
npmtsOra.start();
|
||||||
|
|
||||||
|
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 let promisechain = function(){
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
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!");
|
||||||
|
}
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
18
ts/npmts.publish.ts
Normal file
18
ts/npmts.publish.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/// <reference path="./typings/index.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;
|
||||||
|
};
|
90
ts/npmts.tests.ts
Normal file
90
ts/npmts.tests.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/// <reference path="./typings/index.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
|
|
||||||
|
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) {
|
||||||
|
npmtsOra.text("Instrumentalizing transpiled JS...");
|
||||||
|
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(){
|
||||||
|
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
},"atEnd"));
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
let mocha = function (configArg) {
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
npmtsOra.end(); // end npmtsOra for tests.
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
export let run = function(configArg) {
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let config = configArg;
|
||||||
|
|
||||||
|
npmtsOra.text("now starting tests");
|
||||||
|
plugins.beautylog.log(
|
||||||
|
"-------------------------------------------------------\n" +
|
||||||
|
"*************************** TESTS: ***************************\n" +
|
||||||
|
"--------------------------------------------------------------"
|
||||||
|
);
|
||||||
|
|
||||||
|
istanbul(config)
|
||||||
|
.then(mocha)
|
||||||
|
.then(coverage)
|
||||||
|
.then(done.resolve);
|
||||||
|
return done.promise;
|
||||||
|
};
|
18
ts/tsd.json
18
ts/tsd.json
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
8
ts/typings.json
Normal file
8
ts/typings.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"globalDependencies": {
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
123
ts/typings/colors/colors.d.ts
vendored
123
ts/typings/colors/colors.d.ts
vendored
@ -1,123 +0,0 @@
|
|||||||
// 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;
|
|
||||||
}
|
|
2090
ts/typings/node/node.d.ts
vendored
2090
ts/typings/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
3
ts/typings/tsd.d.ts
vendored
3
ts/typings/tsd.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
/// <reference path="node/node.d.ts" />
|
|
||||||
/// <reference path="colors/colors.d.ts" />
|
|
||||||
/// <reference path="vinyl/vinyl.d.ts" />
|
|
109
ts/typings/vinyl/vinyl.d.ts
vendored
109
ts/typings/vinyl/vinyl.d.ts
vendored
@ -1,109 +0,0 @@
|
|||||||
// 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' {
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
Reference in New Issue
Block a user