Compare commits
187 Commits
Author | SHA1 | Date | |
---|---|---|---|
71f0a9d37f | |||
5f16cdd830 | |||
966cb88c82 | |||
7f4d72f0d6 | |||
3df47307a3 | |||
e3b84af278 | |||
a6c4a99d82 | |||
8d506f8220 | |||
bd9ed5feb5 | |||
ec28c660dc | |||
9f4299e52a | |||
73c583409e | |||
f8c86f1871 | |||
67130ec2b6 | |||
48fa9d205a | |||
3070584642 | |||
a71ffb2415 | |||
dc2be85236 | |||
964e1ce9ac | |||
fba6e3d4c5 | |||
7df51bad07 | |||
5c7af1e59f | |||
e72f7fe5c6 | |||
da48b987ba | |||
9eabac7022 | |||
00683fbab1 | |||
3434bbf815 | |||
85ac242627 | |||
9b71872d12 | |||
281595f8c8 | |||
83f03994a9 | |||
01837f8420 | |||
b5735e3721 | |||
0dc45f1414 | |||
9d1c3f7457 | |||
017279730a | |||
0b50b14146 | |||
dfa27c0604 | |||
19e839a282 | |||
647e2ec886 | |||
4e267850bf | |||
a52f6a9e9b | |||
23b0ee1472 | |||
c4d58b047c | |||
403b530a60 | |||
7d6caaafce | |||
8f47b95220 | |||
375d5cdfcc | |||
a3b1391b86 | |||
d2f5a81cfb | |||
2bc2d11a2d | |||
ecf0666103 | |||
ad05144bba | |||
1e77aba991 | |||
bb6c07845c | |||
079b049a10 | |||
94f48afbbd | |||
944e9b227c | |||
b83aaf4abf | |||
51a1dd0b1d | |||
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 |
11
.gitignore
vendored
11
.gitignore
vendored
@ -1,8 +1,13 @@
|
|||||||
.idea/
|
.idea/
|
||||||
.c9/
|
.c9/
|
||||||
node_modules/
|
node_modules/
|
||||||
test/**/node_modules/
|
test/assets/**/node_modules/
|
||||||
test/**/typings/
|
test/assets/**/docs/
|
||||||
test/**/coverage/
|
test/assets/**/typings/
|
||||||
|
test/assets/**/coverage/
|
||||||
ts/*.js
|
ts/*.js
|
||||||
ts/*.js.map
|
ts/*.js.map
|
||||||
|
ts/typings/
|
||||||
|
docs/
|
||||||
|
|
||||||
|
.DS_Store
|
61
.gitlab-ci.yml
Normal file
61
.gitlab-ci.yml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
image: hosttoday/ht-docker-node:npmts
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- test
|
||||||
|
- release
|
||||||
|
- trigger
|
||||||
|
- page
|
||||||
|
|
||||||
|
testLEGACY:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci test legacy
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
testLTS:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci test lts
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
testSTABLE:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci test stable
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
script:
|
||||||
|
- npmci publish
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
stage: trigger
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
pages:
|
||||||
|
stage: page
|
||||||
|
script:
|
||||||
|
- npmci test lts
|
||||||
|
- mkdir .public
|
||||||
|
- cp -r test/assets/docs/ .public
|
||||||
|
- cp -r test/assets/coverage/ .public
|
||||||
|
- mv .public public
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
only:
|
||||||
|
- tags
|
@ -1,6 +1,7 @@
|
|||||||
.idea/
|
.idea/
|
||||||
support
|
compile/
|
||||||
compile
|
coverage/
|
||||||
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=
|
||||||
|
7
CHANGELOG
Normal file
7
CHANGELOG
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Please view this file on the master branch, on stable branches it's out of date.
|
||||||
|
|
||||||
|
v 6.0.0 (unreleased)
|
||||||
|
- handle bithound
|
||||||
|
- check package.json
|
||||||
|
- check .gitlab-ci-yml
|
||||||
|
- check appveyor.yml
|
4
CONTRIBUTING.md
Normal file
4
CONTRIBUTING.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Contribution Guide
|
||||||
|
|
||||||
|
This module is developed on the fabulous GitLab.com:
|
||||||
|
https://gitlab.com/pushrocks/npmts
|
@ -1 +0,0 @@
|
|||||||
# README-dev
|
|
156
README.md
156
README.md
@ -2,13 +2,19 @@
|
|||||||
Write npm modules with TypeScript without hassle.
|
Write npm modules with TypeScript without hassle.
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
[](https://travis-ci.org/pushrocks/npmts)
|
[](https://gitlab.com/pushrocks/npmts/commits/master)
|
||||||
|
[](https://ci.appveyor.com/project/philkunz/npmts/branch/master)
|
||||||
[](https://david-dm.org/pushrocks/npmts)
|
[](https://david-dm.org/pushrocks/npmts)
|
||||||
[](https://www.bithound.io/github/pushrocks/npmts/master/dependencies/npm)
|
[](https://www.bithound.io/github/pushrocks/npmts/master/dependencies/npm)
|
||||||
[](https://www.bithound.io/github/pushrocks/npmts)
|
[](https://www.bithound.io/github/pushrocks/npmts)
|
||||||
[](https://coveralls.io/github/pushrocks/npmts?branch=master)
|
[](https://codecov.io/github/pushrocks/npmts?branch=master)
|
||||||
|
|
||||||
## How to use npmts
|
## 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:
|
||||||
@ -25,71 +31,107 @@ Then use it in package.json's script section to trigger a build:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Default behaviour
|
### Default task execution order
|
||||||
|
|
||||||
**Execution order of tasks**
|
|
||||||
|
|
||||||
|
1. Check config in ./npmts.json
|
||||||
|
1. Clean up from any previous builds (old js files)
|
||||||
1. Install typings
|
1. Install typings
|
||||||
2. Transpile TypeScript with inline sourcemaps
|
1. Transpile TypeScript with inline sourcemaps
|
||||||
3. Create Declaration Files
|
1. Create Declaration Files
|
||||||
4. Instrumentalize created JavaScript files with istanbul
|
1. Create JsDoc Documentation
|
||||||
5. Run Tests
|
1. Instrumentalize created JavaScript files with istanbul
|
||||||
6. Create Coverage report
|
1. Run Tests
|
||||||
7. Upload Coverage reports to travis (must be activated, only triggers on travis)
|
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
|
||||||
#### Typings
|
the npmts.json is the main config file. You can use it to customize the behaviour of NPMTS.
|
||||||
**npmts** looks for `./ts/typings.json` by default and installs any defined typings to `.ts/typings/`.
|
|
||||||
You can then reference the ./ts/typings/main.d.ts file in your TypeScript code.
|
|
||||||
|
|
||||||
#### TypeScript
|
|
||||||
by default npmts looks for `./ts/index.ts` and `./ts/test.ts` that will compile to
|
|
||||||
`./index.js` and `./test.js`
|
|
||||||
|
|
||||||
#### Declaration files
|
|
||||||
**npmts** also creates an `index.d.ts` declaration file by default.
|
|
||||||
You can reference it in your package.json like this:
|
|
||||||
|
|
||||||
```json
|
|
||||||
"main": "index.js",
|
|
||||||
"typings": "./index.d.ts",
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Instrumentalize Code
|
|
||||||
npmts instrumentalizes 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 runs `.test/test.js` with mocha.
|
|
||||||
|
|
||||||
Any errors will be shown with reference to their originating source in TypeScript.
|
|
||||||
|
|
||||||
When requiring the module from other TypeScript files,
|
|
||||||
the TypeScript Compiler will use the declaration file to resolve typings.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Custom behaviour
|
|
||||||
Custom behaviour can be achieved through a config file at the root of your package.
|
|
||||||
The file must be named **npmts.json**
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"mode":"custom",
|
"mode":"default",
|
||||||
|
"codecov":{
|
||||||
|
"publish":true,
|
||||||
|
"token":"sometoken"
|
||||||
|
},
|
||||||
"ts":{
|
"ts":{
|
||||||
"./customdir/custom.ts":"./customcompiled.js"
|
"./customdir/*.ts":"./"
|
||||||
|
},
|
||||||
|
"docs": {
|
||||||
|
"publish":true,
|
||||||
|
"destination":"github"
|
||||||
|
},
|
||||||
|
"tsOptions":{
|
||||||
|
"declaration":false,
|
||||||
|
"target":"ES6"
|
||||||
},
|
},
|
||||||
"typings":[
|
"typings":[
|
||||||
"./customdir"
|
"./ts/typings.json",
|
||||||
]
|
"./subts1/typings.json",
|
||||||
|
"./subts2/typings.json",
|
||||||
|
"./customdir/typings.json"
|
||||||
|
],
|
||||||
|
"typingsInclude":"auto",
|
||||||
|
"cli":true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* **mode** can be "default" or "custom"
|
| key | default value | description |
|
||||||
* **ts** You can list as many TypeScript files as you like. The key represents the source TypeScript file, the value the output file.
|
| --- | --- | --- |
|
||||||
* **typings** is an array of all direcories that have a typings.json present. Uses the new typings tool from npm.
|
| `"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/`.
|
||||||
|
|
||||||
## Readme for Devs
|
> Note: You can reference the typings files in any of your TypeScript code with a
|
||||||
There is a [README-dev.md](README-dev.md) in the repo.
|
`/// <reference path="/some/path/main.d.ts">`
|
||||||
This is only of interest for you when looking to contribute to, improve or build upon this package.
|
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
|
||||||
|
|
||||||
|
#### TypeScript
|
||||||
|
by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
|
||||||
|
`./dist/*.js` and `./test/test.js`
|
||||||
|
|
||||||
|
Use commonjs module system for wiring up files.
|
||||||
|
|
||||||
|
#### Declaration files
|
||||||
|
**npmts** also creates an `./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"),
|
||||||
header: require("gulp-header")
|
typings:require("gulp-typings")
|
||||||
},
|
},
|
||||||
mergeStream: require("merge2")
|
mergeStream: require("merge2"),
|
||||||
|
path: require("path")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
paths = {
|
||||||
|
packageBase: plugins.path.resolve(
|
||||||
|
plugins.path.join(__dirname,"../")
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
plugins.beautylog.log('now compiling NPMTS');
|
plugins.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.header('#!/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");
|
28
dist/index.js
vendored
Normal file
28
dist/index.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
/* ================================================== *
|
||||||
|
Starting NPMTS main process.
|
||||||
|
* ================================================== */
|
||||||
|
var early = require("early");
|
||||||
|
early.start("NPMTS");
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
early.stop()
|
||||||
|
.done(function () {
|
||||||
|
var npmtsProjectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.npmtsPackageRoot);
|
||||||
|
var npmtsCli = new plugins.smartcli.Smartcli();
|
||||||
|
npmtsCli.standardTask()
|
||||||
|
.then(function () {
|
||||||
|
plugins.beautylog.figletSync("NPMTS");
|
||||||
|
plugins.beautylog.info("npmts version: " + npmtsProjectInfo.version);
|
||||||
|
try {
|
||||||
|
npmts_promisechain_1.promisechain();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
npmtsCli.addVersion(npmtsProjectInfo.version);
|
||||||
|
npmtsCli.startParse();
|
||||||
|
});
|
19
dist/npmts.assets.js
vendored
Normal file
19
dist/npmts.assets.js
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
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;
|
||||||
|
};
|
30
dist/npmts.clean.js
vendored
Normal file
30
dist/npmts.clean.js
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
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 () {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
npmts_promisechain_1.npmtsOra.text("cleaning " + "typings".yellow + " folder");
|
||||||
|
if (false) {
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
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;
|
||||||
|
};
|
2
dist/npmts.cli.js
vendored
Normal file
2
dist/npmts.cli.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
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 (tsArrayArg, keyArg) {
|
||||||
|
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, tsArrayArg[keyArg]));
|
||||||
|
};
|
||||||
|
exports.checkOutputPath = function (tsArrayArg, keyArg) {
|
||||||
|
if (!outputPathIsDir(tsArrayArg, keyArg)) {
|
||||||
|
plugins.beautylog.warn("Skipping " + keyArg + " because " + tsArrayArg[keyArg] + " it is no directory!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
};
|
85
dist/npmts.compile.js
vendored
Normal file
85
dist/npmts.compile.js
vendored
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
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 TS file and thus no definitions found!");
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
var compileTs = function (tsFileArrayArg, tsOptionsArg) {
|
||||||
|
if (tsOptionsArg === void 0) { tsOptionsArg = {}; }
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var moduleStream = plugins.merge2({ end: false });
|
||||||
|
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, tsOptionsArg);
|
||||||
|
};
|
||||||
|
for (var keyArg in tsFileArrayArg) {
|
||||||
|
if (helpers.checkOutputPath(tsFileArrayArg, 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(tsFileArrayArg[keyArg]));
|
||||||
|
var declarationStream = tsStream.dts
|
||||||
|
.pipe(plugins.gulp.dest(tsFileArrayArg[keyArg]));
|
||||||
|
moduleStream.add(tsStream, jsStream, declarationStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
moduleStream.on("queueDrain", function () {
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
npmts_promisechain_1.npmtsOra.text("now compiling " + "TypeScript".yellow);
|
||||||
|
compileTs(config.ts, config.tsOptions)
|
||||||
|
.then(function () {
|
||||||
|
compileTs(config.testTs);
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
plugins.beautylog.ok("compiled TypeScript!");
|
||||||
|
definitionHandler(config)
|
||||||
|
.then(function () {
|
||||||
|
done.resolve(config);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
/*==================== 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";
|
||||||
|
require("typings-global");
|
||||||
|
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";
|
||||||
|
require("typings-global");
|
||||||
|
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;
|
||||||
|
};
|
28
dist/npmts.jsdoc.js
vendored
Normal file
28
dist/npmts.jsdoc.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
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.run = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
genJsdoc(configArg)
|
||||||
|
.then(done.resolve);
|
||||||
|
return done.promise;
|
||||||
|
};
|
36
dist/npmts.options.js
vendored
Normal file
36
dist/npmts.options.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
exports.isCi = function () {
|
||||||
|
return plugins.smartci.check.isCi();
|
||||||
|
};
|
||||||
|
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
|
||||||
|
);
|
||||||
|
config.testTs = (_b = {},
|
||||||
|
_b["./test/test.ts"] = "./test/",
|
||||||
|
_b
|
||||||
|
);
|
||||||
|
config.test = ["./index.js"];
|
||||||
|
}
|
||||||
|
//check if config.tsOptions is available
|
||||||
|
config.tsOptions ? void (0) : config.tsOptions = {};
|
||||||
|
config.coverageTreshold ? void (0) : config.coverageTreshold = 70;
|
||||||
|
// handle docs
|
||||||
|
config.docs ? void (0) : config.docs = {};
|
||||||
|
plugins.beautylog.ok("build options are ready!");
|
||||||
|
done.resolve(config);
|
||||||
|
return done.promise;
|
||||||
|
var _a, _b;
|
||||||
|
};
|
18
dist/npmts.paths.js
vendored
Normal file
18
dist/npmts.paths.js
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
//Npmts Paths
|
||||||
|
exports.npmtsPackageRoot = plugins.path.join(__dirname, "../");
|
||||||
|
//Project paths
|
||||||
|
exports.cwd = process.cwd();
|
||||||
|
//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");
|
29
dist/npmts.plugins.js
vendored
Normal file
29
dist/npmts.plugins.js
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
exports.beautylog = require("beautylog");
|
||||||
|
exports.fs = require("fs-extra");
|
||||||
|
exports.gulp = require("gulp");
|
||||||
|
exports.g = {
|
||||||
|
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";
|
||||||
|
require("typings-global");
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
exports.npmtsOra = new plugins.beautylog.Ora("setting up TaskChain", "cyan");
|
||||||
|
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();
|
||||||
|
exports.npmtsOra.start();
|
||||||
|
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;
|
||||||
|
};
|
9
dist/npmts.publish.js
vendored
Normal file
9
dist/npmts.publish.js
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
done.resolve();
|
||||||
|
return done.promise;
|
||||||
|
};
|
68
dist/npmts.tests.js
vendored
Normal file
68
dist/npmts.tests.js
vendored
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
"use strict";
|
||||||
|
require("typings-global");
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var npmts_promisechain_1 = require("./npmts.promisechain");
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @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;
|
||||||
|
};
|
63
index.d.ts
vendored
63
index.d.ts
vendored
@ -1,63 +0,0 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
|
||||||
declare module NpmtsPlugins {
|
|
||||||
var init: () => {
|
|
||||||
beautylog: any;
|
|
||||||
fs: any;
|
|
||||||
gulp: any;
|
|
||||||
g: {
|
|
||||||
coveralls: any;
|
|
||||||
header: any;
|
|
||||||
istanbul: any;
|
|
||||||
mocha: any;
|
|
||||||
sourcemaps: any;
|
|
||||||
typescript: any;
|
|
||||||
};
|
|
||||||
mergeStream: any;
|
|
||||||
sourceMapSupport: any;
|
|
||||||
path: any;
|
|
||||||
q: any;
|
|
||||||
smartcli: any;
|
|
||||||
smartfile: any;
|
|
||||||
typings: any;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
declare module NpmtsPaths {
|
|
||||||
var init: () => any;
|
|
||||||
}
|
|
||||||
declare module NpmtsConfigFile {
|
|
||||||
var run: () => any;
|
|
||||||
}
|
|
||||||
declare module NpmtsOptions {
|
|
||||||
var run: (configArg: any) => any;
|
|
||||||
}
|
|
||||||
declare module NpmtsCompile {
|
|
||||||
var run: (configArg: any) => any;
|
|
||||||
}
|
|
||||||
declare module NpmtsTests {
|
|
||||||
var run: (configArg: any) => any;
|
|
||||||
}
|
|
||||||
declare module NpmtsPromisechain {
|
|
||||||
var init: () => any;
|
|
||||||
}
|
|
||||||
declare var plugins: {
|
|
||||||
beautylog: any;
|
|
||||||
fs: any;
|
|
||||||
gulp: any;
|
|
||||||
g: {
|
|
||||||
coveralls: any;
|
|
||||||
header: any;
|
|
||||||
istanbul: any;
|
|
||||||
mocha: any;
|
|
||||||
sourcemaps: any;
|
|
||||||
typescript: any;
|
|
||||||
};
|
|
||||||
mergeStream: any;
|
|
||||||
sourceMapSupport: any;
|
|
||||||
path: any;
|
|
||||||
q: any;
|
|
||||||
smartcli: any;
|
|
||||||
smartfile: any;
|
|
||||||
typings: any;
|
|
||||||
};
|
|
||||||
declare var paths: any;
|
|
||||||
declare var promisechain: any;
|
|
262
index.js
262
index.js
@ -1,262 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsPlugins;
|
|
||||||
(function (NpmtsPlugins) {
|
|
||||||
NpmtsPlugins.init = function () {
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
fs: require("fs-extra"),
|
|
||||||
gulp: require("gulp"),
|
|
||||||
g: {
|
|
||||||
coveralls: require("gulp-coveralls"),
|
|
||||||
header: require("gulp-header"),
|
|
||||||
istanbul: require("gulp-istanbul"),
|
|
||||||
mocha: require("gulp-mocha"),
|
|
||||||
sourcemaps: require("gulp-sourcemaps"),
|
|
||||||
typescript: require("gulp-typescript")
|
|
||||||
},
|
|
||||||
mergeStream: require("merge2"),
|
|
||||||
sourceMapSupport: require("source-map-support").install(),
|
|
||||||
path: require("path"),
|
|
||||||
q: require("q"),
|
|
||||||
smartcli: require("smartcli"),
|
|
||||||
smartfile: require("smartfile"),
|
|
||||||
typings: require("typings")
|
|
||||||
};
|
|
||||||
return plugins;
|
|
||||||
};
|
|
||||||
})(NpmtsPlugins || (NpmtsPlugins = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsPaths;
|
|
||||||
(function (NpmtsPaths) {
|
|
||||||
NpmtsPaths.init = function () {
|
|
||||||
var paths = {};
|
|
||||||
paths.cwd = plugins.smartcli.get.cwd().path;
|
|
||||||
paths.tsDir = plugins.path.join(paths.cwd, "ts/");
|
|
||||||
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
|
||||||
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
|
|
||||||
paths.testDir = plugins.path.join(paths.cwd, "test/");
|
|
||||||
return paths;
|
|
||||||
};
|
|
||||||
})(NpmtsPaths || (NpmtsPaths = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsConfigFile;
|
|
||||||
(function (NpmtsConfigFile) {
|
|
||||||
NpmtsConfigFile.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.readFileToObject(configPath);
|
|
||||||
switch (config.mode) {
|
|
||||||
case "default":
|
|
||||||
case "custom":
|
|
||||||
plugins.beautylog.log("mode is " + config.mode.yellow);
|
|
||||||
done.resolve(config);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
|
||||||
config.mode = "default";
|
|
||||||
done.resolve(config);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
})(NpmtsConfigFile || (NpmtsConfigFile = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsOptions;
|
|
||||||
(function (NpmtsOptions) {
|
|
||||||
NpmtsOptions.run = function (configArg) {
|
|
||||||
var done = plugins.q.defer();
|
|
||||||
var config = configArg;
|
|
||||||
if (typeof config.coveralls === "undefined") {
|
|
||||||
config.coveralls = false;
|
|
||||||
}
|
|
||||||
if (config.mode == "default") {
|
|
||||||
config.typings = [
|
|
||||||
"./ts/"
|
|
||||||
];
|
|
||||||
config.ts = (_a = {},
|
|
||||||
_a["./ts/index.ts"] = "./index.js",
|
|
||||||
_a["./ts/test.ts"] = "./test/test.js",
|
|
||||||
_a
|
|
||||||
);
|
|
||||||
config.test = ["./index.js"];
|
|
||||||
done.resolve(config);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
done.resolve(config);
|
|
||||||
}
|
|
||||||
return done.promise;
|
|
||||||
var _a;
|
|
||||||
};
|
|
||||||
})(NpmtsOptions || (NpmtsOptions = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsCompile;
|
|
||||||
(function (NpmtsCompile) {
|
|
||||||
NpmtsCompile.run = function (configArg) {
|
|
||||||
var done = plugins.q.defer();
|
|
||||||
var config = configArg;
|
|
||||||
plugins.beautylog.log("now running custom tasks");
|
|
||||||
var moduleStream = plugins.mergeStream({ end: false });
|
|
||||||
/* -------------------------------------------------
|
|
||||||
* ----------- first install typings ---------------
|
|
||||||
* ----------------------------------------------- */
|
|
||||||
var typingsDone = plugins.q.defer();
|
|
||||||
var typingsCounter = 0;
|
|
||||||
var typingsCounterAdvance = function () {
|
|
||||||
typingsCounter++;
|
|
||||||
if (typeof config.typings[typingsCounter] != "undefined") {
|
|
||||||
installTypings();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugins.beautylog.success("custom typings installed successfully");
|
|
||||||
typingsDone.resolve();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var installTypings = function () {
|
|
||||||
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
|
|
||||||
plugins.typings.install({ production: false, cwd: plugins.path.join(paths.cwd, config.typings[typingsCounter]) })
|
|
||||||
.then(function () {
|
|
||||||
typingsCounterAdvance();
|
|
||||||
}, function () {
|
|
||||||
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
|
|
||||||
typingsCounterAdvance();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
installTypings();
|
|
||||||
/* -------------------------------------------------
|
|
||||||
* ----------- second compile TS -------------------
|
|
||||||
* ----------------------------------------------- */
|
|
||||||
typingsDone.promise.then(function () {
|
|
||||||
for (var key in config.ts) {
|
|
||||||
plugins.beautylog.log("now compiling" + key.blue);
|
|
||||||
var outputPathIsDir;
|
|
||||||
try {
|
|
||||||
if (plugins.fs.statSync(plugins.path.join(paths.cwd, config.ts[key])).isDirectory()) {
|
|
||||||
outputPathIsDir = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
outputPathIsDir = false;
|
|
||||||
}
|
|
||||||
//do some evaluation of the environment
|
|
||||||
var outputNameSpecified = (!outputPathIsDir
|
|
||||||
&& (plugins.path.extname(config.ts[key]) == ".js"));
|
|
||||||
var outputName = (function () {
|
|
||||||
if (outputNameSpecified) {
|
|
||||||
return plugins.path.basename(config.ts[key]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
var outputDir = (function () {
|
|
||||||
if (outputNameSpecified) {
|
|
||||||
return plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return plugins.path.join(paths.cwd, config.ts[key]);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd, key))
|
|
||||||
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
|
||||||
.pipe(plugins.g.typescript({
|
|
||||||
out: outputName,
|
|
||||||
declaration: true,
|
|
||||||
target: "ES5",
|
|
||||||
module: "commonjs"
|
|
||||||
}));
|
|
||||||
var stream = plugins.mergeStream([
|
|
||||||
tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
|
|
||||||
tsStream.js
|
|
||||||
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
|
||||||
.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
|
|
||||||
.pipe(plugins.gulp.dest(outputDir))
|
|
||||||
]);
|
|
||||||
moduleStream.add(stream);
|
|
||||||
}
|
|
||||||
moduleStream.on("queueDrain", function () {
|
|
||||||
plugins.beautylog.success("custom TypeScript installed successfully");
|
|
||||||
moduleStream.on("finish", function () {
|
|
||||||
done.resolve(config);
|
|
||||||
});
|
|
||||||
moduleStream.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
})(NpmtsCompile || (NpmtsCompile = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsTests;
|
|
||||||
(function (NpmtsTests) {
|
|
||||||
NpmtsTests.run = function (configArg) {
|
|
||||||
var done = plugins.q.defer();
|
|
||||||
var config = configArg;
|
|
||||||
var istanbul = function () {
|
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "index.js")])
|
|
||||||
.pipe(plugins.g.istanbul())
|
|
||||||
.pipe(plugins.g.istanbul.hookRequire());
|
|
||||||
return stream;
|
|
||||||
};
|
|
||||||
var mocha = function () {
|
|
||||||
var stream = plugins.gulp.src(["./test/test.js"])
|
|
||||||
.pipe(plugins.g.mocha())
|
|
||||||
.pipe(plugins.g.istanbul.writeReports())
|
|
||||||
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
|
||||||
return stream;
|
|
||||||
};
|
|
||||||
var coveralls = function () {
|
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
|
|
||||||
.pipe(plugins.g.coveralls());
|
|
||||||
return stream;
|
|
||||||
};
|
|
||||||
istanbul().on("finish", function () {
|
|
||||||
mocha().on("finish", function () {
|
|
||||||
if (process.env.TRAVIS && config.coveralls) {
|
|
||||||
coveralls().on("finish", function () {
|
|
||||||
done.resolve(config);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
done.resolve(config);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
};
|
|
||||||
})(NpmtsTests || (NpmtsTests = {}));
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var NpmtsPromisechain;
|
|
||||||
(function (NpmtsPromisechain) {
|
|
||||||
NpmtsPromisechain.init = function () {
|
|
||||||
var promisechain;
|
|
||||||
NpmtsConfigFile.run()
|
|
||||||
.then(NpmtsOptions.run)
|
|
||||||
.then(NpmtsCompile.run)
|
|
||||||
.then(NpmtsTests.run);
|
|
||||||
return promisechain;
|
|
||||||
};
|
|
||||||
})(NpmtsPromisechain || (NpmtsPromisechain = {}));
|
|
||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
/// <reference path="./npmts.plugins.ts" />
|
|
||||||
/// <reference path="./npmts.cli.ts" />
|
|
||||||
/// <reference path="./npmts.paths.ts" />
|
|
||||||
/// <reference path="./npmts.configfile.ts" />
|
|
||||||
/// <reference path="./npmts.options.ts" />
|
|
||||||
/// <reference path="./npmts.compile.ts" />
|
|
||||||
/// <reference path="./npmts.tests.ts" />
|
|
||||||
/// <reference path="./npmts.promisechain.ts" />
|
|
||||||
console.log("**** starting NPMTS ****");
|
|
||||||
var plugins = NpmtsPlugins.init();
|
|
||||||
plugins.beautylog.figletSync("NPMTS");
|
|
||||||
var paths = NpmtsPaths.init();
|
|
||||||
var promisechain = NpmtsPromisechain.init();
|
|
58
package.json
58
package.json
@ -1,19 +1,20 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "2.4.1",
|
"version": "5.3.1",
|
||||||
"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) && (cd test/assets && node ../../index.js)",
|
"test": "(npm run compile && npm run check && npm run checkVersion)",
|
||||||
"release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)"
|
"check": "(cd ./test/assets && node ../../dist/index.js)",
|
||||||
|
"checkVersion": "cd ./test/assets && node ../../dist/index.js -v",
|
||||||
|
"compile": "(cd compile && node compile.js)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/pushrocks/npmts.git"
|
"url": "git+https://gitlab.com/pushrocks/npmts.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"TypeScript",
|
"TypeScript",
|
||||||
@ -22,25 +23,38 @@
|
|||||||
"author": "Lossless Digital UG (haftungsbeschraenkt)",
|
"author": "Lossless Digital UG (haftungsbeschraenkt)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/pushrocks/npmts/issues"
|
"url": "https://gitlab.com/pushrocks/npmts/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/npmts#readme",
|
"homepage": "https://gitlab.com/pushrocks/npmts#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "2.1.1",
|
"beautylog": "5.0.8",
|
||||||
"fs-extra": "^0.26.5",
|
"early": "^2.0.13",
|
||||||
|
"fs-extra": "^0.30.0",
|
||||||
"gulp": "3.9.1",
|
"gulp": "3.9.1",
|
||||||
"gulp-coveralls": "^0.1.4",
|
"gulp-concat": "^2.6.0",
|
||||||
"gulp-header": "^1.7.1",
|
"gulp-function": "^1.3.6",
|
||||||
"gulp-istanbul": "^0.10.3",
|
"gulp-if": "^2.0.1",
|
||||||
|
"gulp-istanbul": "^1.0.0",
|
||||||
|
"gulp-jsdoc3": "^0.3.0",
|
||||||
"gulp-mocha": "^2.2.0",
|
"gulp-mocha": "^2.2.0",
|
||||||
"gulp-sourcemaps": "^1.6.0",
|
"gulp-replace": "^0.5.4",
|
||||||
"gulp-typescript": "2.11.0",
|
"gulp-sourcemaps": "^2.0.0-alpha",
|
||||||
"gulp-typings": "0.0.0",
|
"gulp-typescript": "2.13.6",
|
||||||
"merge2": "1.0.1",
|
"gulp-typings": "2.0.0",
|
||||||
|
"lodash": "^4.13.1",
|
||||||
|
"merge2": "1.0.2",
|
||||||
|
"projectinfo": "1.0.3",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"smartcli": "0.0.11",
|
"shelljs": "^0.7.0",
|
||||||
"smartfile": "0.0.11",
|
"smartci": "0.0.1",
|
||||||
|
"smartcli": "1.0.1",
|
||||||
|
"smartcov": "0.0.6",
|
||||||
|
"smartenv": "1.2.5",
|
||||||
|
"smartfile": "3.0.10",
|
||||||
|
"smartpath": "3.2.2",
|
||||||
|
"smartstring": "^2.0.6",
|
||||||
"source-map-support": "^0.4.0",
|
"source-map-support": "^0.4.0",
|
||||||
"typings": "^0.6.8"
|
"typings-global": "*"
|
||||||
}
|
},
|
||||||
|
"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==
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDZDQUE2QztBQUM3QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9pbmRleC5kLnRzXCIgLz5cbmxldCB0ZXN0cGx1Z2luID0ge1xuICAgIGxvZ1NvbWV0aGluZzogZnVuY3Rpb24oKXtcbiAgICAgICAgY29uc29sZS5sb2coXCJvbmx5IGZ1bmN0aW9uIGV4ZWN1dGVkXCIpO1xuICAgIH1cbn07XG5tb2R1bGUuZXhwb3J0cyA9IHRlc3RwbHVnaW47Il19
|
4
test/assets/index.d.ts
vendored
4
test/assets/index.d.ts
vendored
@ -1,4 +0,0 @@
|
|||||||
/// <reference path="ts/typings/main.d.ts" />
|
|
||||||
declare var testplugin: {
|
|
||||||
logSomething: () => void;
|
|
||||||
};
|
|
@ -1,11 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
var testplugin = {
|
|
||||||
logSomething: function () {
|
|
||||||
console.log("only function executed");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
module.exports = testplugin;
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxudmFyIHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
|
@ -3,11 +3,17 @@
|
|||||||
"ts":{
|
"ts":{
|
||||||
"./customdir/*.ts":"./"
|
"./customdir/*.ts":"./"
|
||||||
},
|
},
|
||||||
|
"tsOptions":{
|
||||||
|
"target":"ES5"
|
||||||
|
},
|
||||||
"typings":[
|
"typings":[
|
||||||
"./ts",
|
"./ts/typings.json",
|
||||||
"./subts1/",
|
"./subts1/typings.json",
|
||||||
"./subts2/",
|
"./subts2/typings.json",
|
||||||
"./customdir"
|
"./customdir/typings.json"
|
||||||
],
|
],
|
||||||
"coveralls":true
|
"docs": {
|
||||||
|
"publish":true
|
||||||
|
},
|
||||||
|
"cli":true
|
||||||
}
|
}
|
@ -1,13 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "test",
|
"name": "testpackage",
|
||||||
"version": "1.0.0",
|
"version": "2.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/pushrocks/npmts.git"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(npmts)"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
BIN
test/assets/test/.DS_Store
vendored
Normal file
BIN
test/assets/test/.DS_Store
vendored
Normal file
Binary file not shown.
2
test/assets/test/test.d.ts
vendored
2
test/assets/test/test.d.ts
vendored
@ -1,2 +1,2 @@
|
|||||||
/// <reference path="ts/typings/main.d.ts" />
|
/// <reference path="../ts/typings/index.d.ts" />
|
||||||
declare var testplugin: any;
|
declare var testplugin: any;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
/// <reference path="../ts/typings/index.d.ts" />
|
||||||
|
var testplugin = require("../dist/index.js");
|
||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
console.log("**** starting test ****");
|
|
||||||
var testplugin = require("../index.js");
|
|
||||||
describe("testplugins", function () {
|
describe("testplugins", function () {
|
||||||
describe(".logSomething", function () {
|
describe(".logSomething", function () {
|
||||||
it("should log something", function () {
|
it("should log something", function () {
|
||||||
@ -11,4 +8,4 @@ describe("testplugins", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsNENBQTRDO0FBQzVDLE9BQU8sQ0FBQyxHQUFHLENBQUMseUJBQXlCLENBQUMsQ0FBQztBQUN2QyxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsYUFBYSxDQUFDLENBQUM7QUFDeEMsUUFBUSxDQUFDLGFBQWEsRUFBQztJQUNuQixRQUFRLENBQUMsZUFBZSxFQUFDO1FBQ3JCLEVBQUUsQ0FBQyxzQkFBc0IsRUFBQztZQUN0QixVQUFVLENBQUMsWUFBWSxFQUFFLENBQUE7UUFDN0IsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUMsQ0FBQztBQUNQLENBQUMsQ0FBQyxDQUFDIiwiZmlsZSI6InRlc3QuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi90eXBpbmdzL21haW4uZC50c1wiIC8+XG5jb25zb2xlLmxvZyhcIioqKiogc3RhcnRpbmcgdGVzdCAqKioqXCIpO1xudmFyIHRlc3RwbHVnaW4gPSByZXF1aXJlKFwiLi4vaW5kZXguanNcIik7XG5kZXNjcmliZShcInRlc3RwbHVnaW5zXCIsZnVuY3Rpb24oKXtcbiAgICBkZXNjcmliZShcIi5sb2dTb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICBpdChcInNob3VsZCBsb2cgc29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIHRlc3RwbHVnaW4ubG9nU29tZXRoaW5nKClcbiAgICAgICAgfSk7XG4gICAgfSk7XG59KTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsaURBQWlEO0FBQ2pELElBQUksVUFBVSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzdDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixFQUFFLENBQUMsc0JBQXNCLEVBQUM7WUFDdEIsVUFBVSxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQzdCLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvaW5kZXguZC50c1wiIC8+XG52YXIgdGVzdHBsdWdpbiA9IHJlcXVpcmUoXCIuLi9kaXN0L2luZGV4LmpzXCIpO1xuZGVzY3JpYmUoXCJ0ZXN0cGx1Z2luc1wiLGZ1bmN0aW9uKCl7XG4gICAgZGVzY3JpYmUoXCIubG9nU29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgaXQoXCJzaG91bGQgbG9nIHNvbWV0aGluZ1wiLGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICB0ZXN0cGx1Z2luLmxvZ1NvbWV0aGluZygpXG4gICAgICAgIH0pO1xuICAgIH0pO1xufSk7Il19
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="../ts/typings/index.d.ts" />
|
||||||
console.log("**** starting test ****");
|
var testplugin = require("../dist/index.js");
|
||||||
var testplugin = require("../index.js");
|
|
||||||
describe("testplugins",function(){
|
describe("testplugins",function(){
|
||||||
describe(".logSomething",function(){
|
describe(".logSomething",function(){
|
||||||
it("should log something",function(){
|
it("should log something",function(){
|
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"
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +0,0 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
var testplugin = {
|
|
||||||
logSomething: function () {
|
|
||||||
console.log("only function executed");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
module.exports = testplugin;
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,IAAI,UAAU,GAAG;IACb,YAAY,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAC;AACF,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC"}
|
|
@ -1,5 +1,5 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/index.d.ts" />
|
||||||
var testplugin = {
|
let testplugin = {
|
||||||
logSomething: function(){
|
logSomething: function(){
|
||||||
console.log("only function executed");
|
console.log("only function executed");
|
||||||
}
|
}
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
console.log("**** starting test ****");
|
|
||||||
var testplugin = require("../index.js");
|
|
||||||
describe("testplugins", function () {
|
|
||||||
describe(".logSomething", function () {
|
|
||||||
it("should log something", function () {
|
|
||||||
testplugin.logSomething();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=test.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AACvC,IAAI,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACxC,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"}
|
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"ambientDependencies": {
|
"globalDependencies": {
|
||||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
|
||||||
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
||||||
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts",
|
||||||
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
test/assets/tsfile1.d.ts
vendored
1
test/assets/tsfile1.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
declare var something: string;
|
|
@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
var something = "something";
|
var something = "something";
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRzZmlsZTEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsSUFBSSxTQUFTLEdBQUcsV0FBVyxDQUFDIiwiZmlsZSI6InRzZmlsZTEuanMiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgc29tZXRoaW5nID0gXCJzb21ldGhpbmdcIjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
||||||
|
44
ts/index.ts
44
ts/index.ts
@ -1,14 +1,30 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
import "typings-global";
|
||||||
/// <reference path="./npmts.plugins.ts" />
|
|
||||||
/// <reference path="./npmts.cli.ts" />
|
/* ================================================== *
|
||||||
/// <reference path="./npmts.paths.ts" />
|
Starting NPMTS main process.
|
||||||
/// <reference path="./npmts.configfile.ts" />
|
* ================================================== */
|
||||||
/// <reference path="./npmts.options.ts" />
|
import * as early from "early";
|
||||||
/// <reference path="./npmts.compile.ts" />
|
early.start("NPMTS");
|
||||||
/// <reference path="./npmts.tests.ts" />
|
import * as plugins from "./npmts.plugins"
|
||||||
/// <reference path="./npmts.promisechain.ts" />
|
import * as paths from "./npmts.paths";
|
||||||
console.log("**** starting NPMTS ****");
|
import {promisechain} from "./npmts.promisechain";
|
||||||
var plugins = NpmtsPlugins.init();
|
early.stop()
|
||||||
plugins.beautylog.figletSync("NPMTS");
|
.done(() => {
|
||||||
var paths = NpmtsPaths.init();
|
let npmtsProjectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.npmtsPackageRoot);
|
||||||
var promisechain = NpmtsPromisechain.init();
|
|
||||||
|
let npmtsCli = new plugins.smartcli.Smartcli();
|
||||||
|
npmtsCli.standardTask()
|
||||||
|
.then(() => {
|
||||||
|
plugins.beautylog.figletSync("NPMTS");
|
||||||
|
plugins.beautylog.info("npmts version: " + npmtsProjectInfo.version);
|
||||||
|
try {
|
||||||
|
promisechain();
|
||||||
|
}
|
||||||
|
catch(err){
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
npmtsCli.addVersion(npmtsProjectInfo.version);
|
||||||
|
npmtsCli.startParse();
|
||||||
|
});
|
18
ts/npmts.assets.ts
Normal file
18
ts/npmts.assets.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import "typings-global";
|
||||||
|
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;
|
||||||
|
};
|
33
ts/npmts.clean.ts
Normal file
33
ts/npmts.clean.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import "typings-global";
|
||||||
|
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(){
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
npmtsOra.text("cleaning " + "typings".yellow + " folder");
|
||||||
|
if(false){
|
||||||
|
//plugins.smartfile.fsaction.remove(paths.typingsDir)
|
||||||
|
// .then(done.resolve);
|
||||||
|
} else {
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
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" />
|
import "typings-global";
|
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 (tsArrayArg,keyArg) {
|
||||||
|
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, tsArrayArg[keyArg]));
|
||||||
|
};
|
||||||
|
|
||||||
|
export let checkOutputPath = function(tsArrayArg,keyArg){
|
||||||
|
if(!outputPathIsDir(tsArrayArg,keyArg)) {
|
||||||
|
plugins.beautylog.warn("Skipping " + keyArg + " because " + tsArrayArg[keyArg] + " it is no directory!")
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
@ -1,97 +1,94 @@
|
|||||||
/// <reference path="./index.ts" />
|
import "typings-global";
|
||||||
module NpmtsCompile {
|
import plugins = require("./npmts.plugins");
|
||||||
export var run = function(configArg){
|
import paths = require("./npmts.paths");
|
||||||
var done = plugins.q.defer();
|
import helpers = require("./npmts.compile.helpers");
|
||||||
var config = configArg;
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
plugins.beautylog.log("now running custom tasks");
|
|
||||||
var moduleStream = plugins.mergeStream({end: false});
|
|
||||||
/* -------------------------------------------------
|
|
||||||
* ----------- first install typings ---------------
|
|
||||||
* ----------------------------------------------- */
|
|
||||||
var typingsDone = plugins.q.defer();
|
|
||||||
var typingsCounter:number = 0;
|
|
||||||
var typingsCounterAdvance = function(){
|
|
||||||
typingsCounter++;
|
|
||||||
if(typeof config.typings[typingsCounter] != "undefined"){
|
|
||||||
installTypings();
|
|
||||||
} else {
|
|
||||||
plugins.beautylog.success("custom typings installed successfully");
|
|
||||||
typingsDone.resolve();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var installTypings = function() {
|
|
||||||
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
|
|
||||||
plugins.typings.install({production: false, cwd: plugins.path.join(paths.cwd,config.typings[typingsCounter])})
|
|
||||||
.then(function(){
|
|
||||||
typingsCounterAdvance();
|
|
||||||
},function(){
|
|
||||||
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
|
|
||||||
typingsCounterAdvance();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
installTypings();
|
|
||||||
/* -------------------------------------------------
|
|
||||||
* ----------- second compile TS -------------------
|
|
||||||
* ----------------------------------------------- */
|
|
||||||
typingsDone.promise.then(function(){
|
|
||||||
for (var key in config.ts) {
|
|
||||||
plugins.beautylog.log("now compiling" + key.blue);
|
|
||||||
var outputPathIsDir:boolean;
|
|
||||||
try {
|
|
||||||
if(plugins.fs.statSync(plugins.path.join(paths.cwd,config.ts[key])).isDirectory()){
|
|
||||||
outputPathIsDir = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(err) {
|
|
||||||
outputPathIsDir = false;
|
|
||||||
}
|
|
||||||
//do some evaluation of the environment
|
|
||||||
var outputNameSpecified:boolean = (
|
|
||||||
!outputPathIsDir
|
|
||||||
&& (plugins.path.extname(config.ts[key]) == ".js")
|
|
||||||
);
|
|
||||||
var outputName = (function(){
|
|
||||||
if(outputNameSpecified){
|
|
||||||
return plugins.path.basename(config.ts[key])
|
|
||||||
} else {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
var outputDir = (function(){
|
|
||||||
if(outputNameSpecified){
|
|
||||||
return plugins.path.dirname(
|
|
||||||
plugins.path.join(paths.cwd,config.ts[key])
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return plugins.path.join(paths.cwd,config.ts[key])
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd,key))
|
/**
|
||||||
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
* handles definition to make them fit for modular use
|
||||||
.pipe(plugins.g.typescript({
|
*/
|
||||||
out: outputName,
|
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 TS file and thus no definitions found!");
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
let compileTs = (tsFileArrayArg,tsOptionsArg = {}) => {
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let moduleStream = plugins.merge2({ end: false });
|
||||||
|
|
||||||
|
let tsOptionsDefault = {
|
||||||
declaration: true,
|
declaration: true,
|
||||||
target: "ES5",
|
target: "ES5",
|
||||||
module: "commonjs"
|
module: "commonjs"
|
||||||
}));
|
};
|
||||||
var stream = plugins.mergeStream([
|
|
||||||
tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
|
/**
|
||||||
tsStream.js
|
* merges default ts options with those found in npmts.json
|
||||||
|
*/
|
||||||
|
let tsOptions = function (keyArg:string) {
|
||||||
|
return plugins.lodashObject.assign(tsOptionsDefault, tsOptionsArg)
|
||||||
|
};
|
||||||
|
for (let keyArg in tsFileArrayArg) {
|
||||||
|
if (helpers.checkOutputPath(tsFileArrayArg,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.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||||
.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
|
.pipe(plugins.gulp.dest(tsFileArrayArg[keyArg]));
|
||||||
.pipe(plugins.gulp.dest(outputDir))
|
let declarationStream = tsStream.dts
|
||||||
]);
|
.pipe(plugins.gulp.dest(tsFileArrayArg[keyArg]));
|
||||||
moduleStream.add(stream);
|
moduleStream.add(tsStream,jsStream,declarationStream);
|
||||||
}
|
}
|
||||||
moduleStream.on("queueDrain",function(){
|
}
|
||||||
plugins.beautylog.success("custom TypeScript installed successfully");
|
moduleStream.on("queueDrain",() => {
|
||||||
moduleStream.on("finish",function(){
|
done.resolve();
|
||||||
|
})
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export let run = function (configArg) {
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let config = configArg;
|
||||||
|
npmtsOra.text("now compiling " + "TypeScript".yellow);
|
||||||
|
|
||||||
|
compileTs(config.ts,config.tsOptions)
|
||||||
|
.then(() => {
|
||||||
|
compileTs(config.testTs);
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
plugins.beautylog.ok("compiled TypeScript!");
|
||||||
|
definitionHandler(config)
|
||||||
|
.then(function(){
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
});
|
});
|
||||||
moduleStream.end();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
/*==================== END TS Compilation =====================*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
/// <reference path="./index.ts" />
|
import "typings-global";
|
||||||
module NpmtsConfigFile {
|
import plugins = require("./npmts.plugins");
|
||||||
export var run = function(){
|
import paths = require("./npmts.paths");
|
||||||
var done = plugins.q.defer();
|
export var run = function(){
|
||||||
|
var done = plugins.Q.defer();
|
||||||
var config:any = {};
|
var config:any = {};
|
||||||
var configPath = plugins.path.join(paths.cwd,"npmts.json");
|
var configPath = plugins.path.join(paths.cwd,"npmts.json");
|
||||||
if(plugins.smartfile.checks.fileExistsSync(configPath)){
|
if(plugins.smartfile.checks.fileExistsSync(configPath)){
|
||||||
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
||||||
config = plugins.smartfile.readFileToObject(configPath);
|
config = plugins.smartfile.local.toObjectSync(configPath);
|
||||||
switch (config.mode){
|
switch (config.mode){
|
||||||
case "default":
|
case "default":
|
||||||
case "custom":
|
case "custom":
|
||||||
plugins.beautylog.log("mode is " + config.mode.yellow);
|
plugins.beautylog.ok("mode is " + config.mode.yellow);
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
||||||
|
process.exit(1);
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
||||||
@ -22,5 +24,4 @@ module NpmtsConfigFile {
|
|||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
};
|
};
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
};
|
||||||
}
|
|
21
ts/npmts.install.ts
Normal file
21
ts/npmts.install.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import "typings-global";
|
||||||
|
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;
|
||||||
|
};
|
30
ts/npmts.jsdoc.ts
Normal file
30
ts/npmts.jsdoc.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import "typings-global";
|
||||||
|
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 run = function(configArg){
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
genJsdoc(configArg)
|
||||||
|
.then(done.resolve);
|
||||||
|
return done.promise;
|
||||||
|
};
|
@ -1,24 +1,42 @@
|
|||||||
/// <reference path="./index.ts" />
|
import "typings-global";
|
||||||
module NpmtsOptions {
|
import plugins = require("./npmts.plugins");
|
||||||
export var run = function(configArg){
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
var done = plugins.q.defer();
|
|
||||||
|
export let isCi = function(){
|
||||||
|
return plugins.smartci.check.isCi();
|
||||||
|
};
|
||||||
|
|
||||||
|
export var run = function(configArg){
|
||||||
|
var done = plugins.Q.defer();
|
||||||
var config = configArg;
|
var config = configArg;
|
||||||
if (typeof config.coveralls === "undefined"){
|
|
||||||
config.coveralls = false;
|
npmtsOra.text("now determining build options...");
|
||||||
}
|
|
||||||
|
//handle default mode
|
||||||
if (config.mode == "default"){
|
if (config.mode == "default"){
|
||||||
config.typings = [
|
config.typings = [
|
||||||
"./ts/"
|
"./ts/typings.json"
|
||||||
];
|
];
|
||||||
config.ts = {
|
config.ts = {
|
||||||
["./ts/index.ts"]: "./index.js",
|
["./ts/**/*.ts"]: "./dist/"
|
||||||
["./ts/test.ts"]: "./test/test.js"
|
};
|
||||||
|
config.testTs = {
|
||||||
|
["./test/test.ts"]: "./test/"
|
||||||
};
|
};
|
||||||
config.test = ["./index.js"];
|
config.test = ["./index.js"];
|
||||||
done.resolve(config);
|
|
||||||
} else {
|
|
||||||
done.resolve(config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check if config.tsOptions is available
|
||||||
|
config.tsOptions ? void(0) : config.tsOptions = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
config.coverageTreshold ? void(0) : config.coverageTreshold = 70;
|
||||||
|
|
||||||
|
// handle docs
|
||||||
|
config.docs ? void(0) : config.docs = {};
|
||||||
|
|
||||||
|
plugins.beautylog.ok("build options are ready!");
|
||||||
|
done.resolve(config);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
};
|
||||||
}
|
|
@ -1,12 +1,23 @@
|
|||||||
/// <reference path="./index.ts" />
|
import "typings-global";
|
||||||
module NpmtsPaths {
|
import plugins = require("./npmts.plugins");
|
||||||
export var init = function() {
|
|
||||||
var paths:any = {};
|
//Npmts Paths
|
||||||
paths.cwd = plugins.smartcli.get.cwd().path;
|
export let npmtsPackageRoot = plugins.path.join(__dirname,"../");
|
||||||
paths.tsDir = plugins.path.join(paths.cwd,"ts/");
|
|
||||||
paths.indexTS = plugins.path.join(paths.cwd,"ts/index.ts");
|
|
||||||
paths.testTS = plugins.path.join(paths.cwd,"ts/test.ts");
|
//Project paths
|
||||||
paths.testDir = plugins.path.join(paths.cwd,"test/");
|
export let cwd = process.cwd();
|
||||||
return paths;
|
|
||||||
}
|
//Directories
|
||||||
}
|
export let tsDir = plugins.path.join(cwd,"ts/");
|
||||||
|
export let distDir = plugins.path.join(cwd,"dist/");
|
||||||
|
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,27 +1,29 @@
|
|||||||
/// <reference path="./index.ts" />
|
import "typings-global";
|
||||||
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 = {
|
||||||
fs: require("fs-extra"),
|
gFunction: require("gulp-function"),
|
||||||
gulp: require("gulp"),
|
|
||||||
g: {
|
|
||||||
coveralls: require("gulp-coveralls"),
|
|
||||||
header: require("gulp-header"),
|
|
||||||
istanbul: require("gulp-istanbul"),
|
istanbul: require("gulp-istanbul"),
|
||||||
|
jsdoc3: require("gulp-jsdoc3"),
|
||||||
mocha: require("gulp-mocha"),
|
mocha: require("gulp-mocha"),
|
||||||
|
replace: require("gulp-replace"),
|
||||||
sourcemaps: require("gulp-sourcemaps"),
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
typescript: require("gulp-typescript")
|
typescript: require("gulp-typescript"),
|
||||||
|
typings: require("gulp-typings")
|
||||||
|
|
||||||
},
|
};
|
||||||
mergeStream: require("merge2"),
|
export let lodashObject = require('lodash/fp/object');
|
||||||
sourceMapSupport:require("source-map-support").install(),
|
export let merge2 = require("merge2");
|
||||||
path: require("path"),
|
export import projectinfo = require("projectinfo");
|
||||||
q:require("q"),
|
export let path = require("path");
|
||||||
smartcli: require("smartcli"),
|
export let Q = require("q");
|
||||||
smartfile: require("smartfile"),
|
export let shelljs = require("shelljs");
|
||||||
typings: require("typings")
|
export let smartci = require("smartci");
|
||||||
};
|
export import smartcli = require("smartcli");
|
||||||
return plugins;
|
export let smartcov = require("smartcov");
|
||||||
}
|
export import smartenv = require("smartenv");
|
||||||
}
|
export import 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
|
@ -1,11 +1,52 @@
|
|||||||
/// <reference path="./index.ts" />
|
import "typings-global";
|
||||||
module NpmtsPromisechain {
|
import plugins = require("./npmts.plugins");
|
||||||
export var init = function(){
|
|
||||||
var promisechain;
|
export let npmtsOra = new plugins.beautylog.Ora("setting up TaskChain","cyan");
|
||||||
|
|
||||||
|
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();
|
||||||
|
npmtsOra.start();
|
||||||
NpmtsConfigFile.run()
|
NpmtsConfigFile.run()
|
||||||
.then(NpmtsOptions.run)
|
.then(NpmtsOptions.run)
|
||||||
|
.then(NpmtsClean.run)
|
||||||
|
.then(NpmtsInstall.run)
|
||||||
.then(NpmtsCompile.run)
|
.then(NpmtsCompile.run)
|
||||||
.then(NpmtsTests.run);
|
.then(NpmtsAssets.run)
|
||||||
return promisechain;
|
.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;
|
||||||
|
};
|
11
ts/npmts.publish.ts
Normal file
11
ts/npmts.publish.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import "typings-global";
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
import NpmtsJsdoc = require("./npmts.jsdoc");
|
||||||
|
|
||||||
|
export let run = function(configArg){
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let config = configArg;
|
||||||
|
done.resolve();
|
||||||
|
return done.promise;
|
||||||
|
};
|
@ -1,44 +1,78 @@
|
|||||||
/// <reference path="./index.ts" />
|
import "typings-global";
|
||||||
module NpmtsTests {
|
import plugins = require("./npmts.plugins");
|
||||||
export var run = function(configArg) {
|
import paths = require("./npmts.paths");
|
||||||
var done = plugins.q.defer();
|
import {npmtsOra} from "./npmts.promisechain";
|
||||||
var config = configArg;
|
|
||||||
var istanbul = function () {
|
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"index.js")])
|
|
||||||
// Covering files
|
|
||||||
.pipe(plugins.g.istanbul())
|
|
||||||
// Force `require` to return covered files
|
|
||||||
.pipe(plugins.g.istanbul.hookRequire());
|
|
||||||
return stream;
|
|
||||||
};
|
|
||||||
|
|
||||||
var mocha = function () {
|
/**
|
||||||
var stream = plugins.gulp.src(["./test/test.js"])
|
*
|
||||||
|
* @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.mocha())
|
||||||
// Creating the reports after tests ran
|
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
|
||||||
.pipe(plugins.g.istanbul.writeReports())
|
.pipe(plugins.g.gFunction(function(){
|
||||||
// Enforce a coverage of at least 90%
|
plugins.beautylog.ok("Tests have passed!");
|
||||||
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
done.resolve(configArg);
|
||||||
return stream;
|
},"atEnd"));
|
||||||
};
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
var coveralls = function(){
|
let coverage = function(configArg){
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
|
let done = plugins.Q.defer();
|
||||||
.pipe(plugins.g.coveralls());
|
plugins.smartcov.get.percentage(plugins.path.join(paths.coverageDir,"lcov.info"))
|
||||||
return stream;
|
.then(function(percentageArg){
|
||||||
};
|
if (percentageArg >= configArg.coverageTreshold){
|
||||||
|
plugins.beautylog.ok(
|
||||||
istanbul().on("finish",function(){
|
"your coverage of " + percentageArg.toString().blue + "% ".blue + "exceeds your treshold of " +
|
||||||
mocha().on("finish",function(){
|
configArg.coverageTreshold.toString().blue + "%".blue
|
||||||
if(process.env.TRAVIS && config.coveralls){
|
);
|
||||||
coveralls().on("finish",function(){
|
|
||||||
done.resolve(config);
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
done.resolve(config);
|
plugins.beautylog.warn(
|
||||||
|
"your coverage of " + percentageArg + "% " + "fails your treshold of " +
|
||||||
|
configArg.coverageTreshold + "%"
|
||||||
|
);
|
||||||
|
plugins.beautylog.error("exiting due to coverage failure");
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
})
|
done.resolve(configArg);
|
||||||
});
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
export let run = function(configArg) {
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let config = configArg;
|
||||||
|
|
||||||
|
npmtsOra.text("now starting tests");
|
||||||
|
plugins.beautylog.log(
|
||||||
|
"-------------------------------------------------------\n" +
|
||||||
|
"*************************** TESTS: ***************************\n" +
|
||||||
|
"--------------------------------------------------------------"
|
||||||
|
);
|
||||||
|
|
||||||
|
istanbul(config)
|
||||||
|
.then(mocha)
|
||||||
|
.then(coverage)
|
||||||
|
.then(done.resolve);
|
||||||
|
return done.promise;
|
||||||
|
};
|
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"ambientDependencies": {
|
"globalDependencies": {
|
||||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
|
||||||
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
"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"
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
ts/typings/browser.d.ts
vendored
3
ts/typings/browser.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
/// <reference path="browser/ambient/colors/colors.d.ts" />
|
|
||||||
/// <reference path="browser/ambient/node/node.d.ts" />
|
|
||||||
/// <reference path="browser/ambient/vinyl/vinyl.d.ts" />
|
|
125
ts/typings/browser/ambient/colors/colors.d.ts
vendored
125
ts/typings/browser/ambient/colors/colors.d.ts
vendored
@ -1,125 +0,0 @@
|
|||||||
// Compiled using typings@0.6.3
|
|
||||||
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/09e37435ffb2c56a6f908081194a74756f24f99d/colors/colors.d.ts
|
|
||||||
// Type definitions for Colors.js 0.6.0-1
|
|
||||||
// Project: https://github.com/Marak/colors.js
|
|
||||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
|
||||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
|
||||||
|
|
||||||
declare module "colors" {
|
|
||||||
interface Color {
|
|
||||||
(text: string): string;
|
|
||||||
|
|
||||||
black: Color;
|
|
||||||
red: Color;
|
|
||||||
green: Color;
|
|
||||||
yellow: Color;
|
|
||||||
blue: Color;
|
|
||||||
magenta: Color;
|
|
||||||
cyan: Color;
|
|
||||||
white: Color;
|
|
||||||
gray: Color;
|
|
||||||
grey: Color;
|
|
||||||
|
|
||||||
bgBlack: Color;
|
|
||||||
bgRed: Color;
|
|
||||||
bgGreen: Color;
|
|
||||||
bgYellow: Color;
|
|
||||||
bgBlue: Color;
|
|
||||||
bgMagenta: Color;
|
|
||||||
bgCyan: Color;
|
|
||||||
bgWhite: Color;
|
|
||||||
|
|
||||||
reset: Color;
|
|
||||||
bold: Color;
|
|
||||||
dim: Color;
|
|
||||||
italic: Color;
|
|
||||||
underline: Color;
|
|
||||||
inverse: Color;
|
|
||||||
hidden: Color;
|
|
||||||
strikethrough: Color;
|
|
||||||
|
|
||||||
rainbow: Color;
|
|
||||||
zebra: Color;
|
|
||||||
america: Color;
|
|
||||||
trap: Color;
|
|
||||||
random: Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
module e {
|
|
||||||
export function setTheme(theme:any): void;
|
|
||||||
|
|
||||||
export var black: Color;
|
|
||||||
export var red: Color;
|
|
||||||
export var green: Color;
|
|
||||||
export var yellow: Color;
|
|
||||||
export var blue: Color;
|
|
||||||
export var magenta: Color;
|
|
||||||
export var cyan: Color;
|
|
||||||
export var white: Color;
|
|
||||||
export var gray: Color;
|
|
||||||
export var grey: Color;
|
|
||||||
|
|
||||||
export var bgBlack: Color;
|
|
||||||
export var bgRed: Color;
|
|
||||||
export var bgGreen: Color;
|
|
||||||
export var bgYellow: Color;
|
|
||||||
export var bgBlue: Color;
|
|
||||||
export var bgMagenta: Color;
|
|
||||||
export var bgCyan: Color;
|
|
||||||
export var bgWhite: Color;
|
|
||||||
|
|
||||||
export var reset: Color;
|
|
||||||
export var bold: Color;
|
|
||||||
export var dim: Color;
|
|
||||||
export var italic: Color;
|
|
||||||
export var underline: Color;
|
|
||||||
export var inverse: Color;
|
|
||||||
export var hidden: Color;
|
|
||||||
export var strikethrough: Color;
|
|
||||||
|
|
||||||
export var rainbow: Color;
|
|
||||||
export var zebra: Color;
|
|
||||||
export var america: Color;
|
|
||||||
export var trap: Color;
|
|
||||||
export var random: Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
export = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface String {
|
|
||||||
black: string;
|
|
||||||
red: string;
|
|
||||||
green: string;
|
|
||||||
yellow: string;
|
|
||||||
blue: string;
|
|
||||||
magenta: string;
|
|
||||||
cyan: string;
|
|
||||||
white: string;
|
|
||||||
gray: string;
|
|
||||||
grey: string;
|
|
||||||
|
|
||||||
bgBlack: string;
|
|
||||||
bgRed: string;
|
|
||||||
bgGreen: string;
|
|
||||||
bgYellow: string;
|
|
||||||
bgBlue: string;
|
|
||||||
bgMagenta: string;
|
|
||||||
bgCyan: string;
|
|
||||||
bgWhite: string;
|
|
||||||
|
|
||||||
reset: string;
|
|
||||||
bold: string;
|
|
||||||
dim: string;
|
|
||||||
italic: string;
|
|
||||||
underline: string;
|
|
||||||
inverse: string;
|
|
||||||
hidden: string;
|
|
||||||
strikethrough: string;
|
|
||||||
|
|
||||||
rainbow: string;
|
|
||||||
zebra: string;
|
|
||||||
america: string;
|
|
||||||
trap: string;
|
|
||||||
random: string;
|
|
||||||
}
|
|
2092
ts/typings/browser/ambient/node/node.d.ts
vendored
2092
ts/typings/browser/ambient/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
110
ts/typings/browser/ambient/vinyl/vinyl.d.ts
vendored
110
ts/typings/browser/ambient/vinyl/vinyl.d.ts
vendored
@ -1,110 +0,0 @@
|
|||||||
// Compiled using typings@0.6.3
|
|
||||||
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/78d36dd49b6b55b9fdfe61776a12bf05c8b07777/vinyl/vinyl.d.ts
|
|
||||||
// Type definitions for vinyl 0.4.3
|
|
||||||
// Project: https://github.com/wearefractal/vinyl
|
|
||||||
// Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao>
|
|
||||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
|
||||||
|
|
||||||
|
|
||||||
declare module 'vinyl' {
|
|
||||||
|
|
||||||
import fs = require('fs');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A virtual file format.
|
|
||||||
*/
|
|
||||||
class File {
|
|
||||||
constructor(options?: {
|
|
||||||
/**
|
|
||||||
* Default: process.cwd()
|
|
||||||
*/
|
|
||||||
cwd?: string;
|
|
||||||
/**
|
|
||||||
* Used for relative pathing. Typically where a glob starts.
|
|
||||||
*/
|
|
||||||
base?: string;
|
|
||||||
/**
|
|
||||||
* Full path to the file.
|
|
||||||
*/
|
|
||||||
path?: string;
|
|
||||||
/**
|
|
||||||
* Path history. Has no effect if options.path is passed.
|
|
||||||
*/
|
|
||||||
history?: string[];
|
|
||||||
/**
|
|
||||||
* The result of an fs.stat call. See fs.Stats for more information.
|
|
||||||
*/
|
|
||||||
stat?: fs.Stats;
|
|
||||||
/**
|
|
||||||
* File contents.
|
|
||||||
* Type: Buffer, Stream, or null
|
|
||||||
*/
|
|
||||||
contents?: Buffer | NodeJS.ReadWriteStream;
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default: process.cwd()
|
|
||||||
*/
|
|
||||||
public cwd: string;
|
|
||||||
/**
|
|
||||||
* Used for relative pathing. Typically where a glob starts.
|
|
||||||
*/
|
|
||||||
public base: string;
|
|
||||||
/**
|
|
||||||
* Full path to the file.
|
|
||||||
*/
|
|
||||||
public path: string;
|
|
||||||
public stat: fs.Stats;
|
|
||||||
/**
|
|
||||||
* Type: Buffer|Stream|null (Default: null)
|
|
||||||
*/
|
|
||||||
public contents: Buffer | NodeJS.ReadableStream;
|
|
||||||
/**
|
|
||||||
* Returns path.relative for the file base and file path.
|
|
||||||
* Example:
|
|
||||||
* var file = new File({
|
|
||||||
* cwd: "/",
|
|
||||||
* base: "/test/",
|
|
||||||
* path: "/test/file.js"
|
|
||||||
* });
|
|
||||||
* console.log(file.relative); // file.js
|
|
||||||
*/
|
|
||||||
public relative: string;
|
|
||||||
|
|
||||||
public isBuffer(): boolean;
|
|
||||||
|
|
||||||
public isStream(): boolean;
|
|
||||||
|
|
||||||
public isNull(): boolean;
|
|
||||||
|
|
||||||
public isDirectory(): boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.
|
|
||||||
*/
|
|
||||||
public clone(opts?: { contents?: boolean }): File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If file.contents is a Buffer, it will write it to the stream.
|
|
||||||
* If file.contents is a Stream, it will pipe it to the stream.
|
|
||||||
* If file.contents is null, it will do nothing.
|
|
||||||
*/
|
|
||||||
public pipe<T extends NodeJS.ReadWriteStream>(
|
|
||||||
stream: T,
|
|
||||||
opts?: {
|
|
||||||
/**
|
|
||||||
* If false, the destination stream will not be ended (same as node core).
|
|
||||||
*/
|
|
||||||
end?: boolean;
|
|
||||||
}
|
|
||||||
): T;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a pretty String interpretation of the File. Useful for console.log.
|
|
||||||
*/
|
|
||||||
public inspect(): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export = File;
|
|
||||||
|
|
||||||
}
|
|
3
ts/typings/main.d.ts
vendored
3
ts/typings/main.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
/// <reference path="main/ambient/colors/colors.d.ts" />
|
|
||||||
/// <reference path="main/ambient/node/node.d.ts" />
|
|
||||||
/// <reference path="main/ambient/vinyl/vinyl.d.ts" />
|
|
125
ts/typings/main/ambient/colors/colors.d.ts
vendored
125
ts/typings/main/ambient/colors/colors.d.ts
vendored
@ -1,125 +0,0 @@
|
|||||||
// Compiled using typings@0.6.3
|
|
||||||
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/09e37435ffb2c56a6f908081194a74756f24f99d/colors/colors.d.ts
|
|
||||||
// Type definitions for Colors.js 0.6.0-1
|
|
||||||
// Project: https://github.com/Marak/colors.js
|
|
||||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
|
||||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
|
||||||
|
|
||||||
declare module "colors" {
|
|
||||||
interface Color {
|
|
||||||
(text: string): string;
|
|
||||||
|
|
||||||
black: Color;
|
|
||||||
red: Color;
|
|
||||||
green: Color;
|
|
||||||
yellow: Color;
|
|
||||||
blue: Color;
|
|
||||||
magenta: Color;
|
|
||||||
cyan: Color;
|
|
||||||
white: Color;
|
|
||||||
gray: Color;
|
|
||||||
grey: Color;
|
|
||||||
|
|
||||||
bgBlack: Color;
|
|
||||||
bgRed: Color;
|
|
||||||
bgGreen: Color;
|
|
||||||
bgYellow: Color;
|
|
||||||
bgBlue: Color;
|
|
||||||
bgMagenta: Color;
|
|
||||||
bgCyan: Color;
|
|
||||||
bgWhite: Color;
|
|
||||||
|
|
||||||
reset: Color;
|
|
||||||
bold: Color;
|
|
||||||
dim: Color;
|
|
||||||
italic: Color;
|
|
||||||
underline: Color;
|
|
||||||
inverse: Color;
|
|
||||||
hidden: Color;
|
|
||||||
strikethrough: Color;
|
|
||||||
|
|
||||||
rainbow: Color;
|
|
||||||
zebra: Color;
|
|
||||||
america: Color;
|
|
||||||
trap: Color;
|
|
||||||
random: Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
module e {
|
|
||||||
export function setTheme(theme:any): void;
|
|
||||||
|
|
||||||
export var black: Color;
|
|
||||||
export var red: Color;
|
|
||||||
export var green: Color;
|
|
||||||
export var yellow: Color;
|
|
||||||
export var blue: Color;
|
|
||||||
export var magenta: Color;
|
|
||||||
export var cyan: Color;
|
|
||||||
export var white: Color;
|
|
||||||
export var gray: Color;
|
|
||||||
export var grey: Color;
|
|
||||||
|
|
||||||
export var bgBlack: Color;
|
|
||||||
export var bgRed: Color;
|
|
||||||
export var bgGreen: Color;
|
|
||||||
export var bgYellow: Color;
|
|
||||||
export var bgBlue: Color;
|
|
||||||
export var bgMagenta: Color;
|
|
||||||
export var bgCyan: Color;
|
|
||||||
export var bgWhite: Color;
|
|
||||||
|
|
||||||
export var reset: Color;
|
|
||||||
export var bold: Color;
|
|
||||||
export var dim: Color;
|
|
||||||
export var italic: Color;
|
|
||||||
export var underline: Color;
|
|
||||||
export var inverse: Color;
|
|
||||||
export var hidden: Color;
|
|
||||||
export var strikethrough: Color;
|
|
||||||
|
|
||||||
export var rainbow: Color;
|
|
||||||
export var zebra: Color;
|
|
||||||
export var america: Color;
|
|
||||||
export var trap: Color;
|
|
||||||
export var random: Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
export = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface String {
|
|
||||||
black: string;
|
|
||||||
red: string;
|
|
||||||
green: string;
|
|
||||||
yellow: string;
|
|
||||||
blue: string;
|
|
||||||
magenta: string;
|
|
||||||
cyan: string;
|
|
||||||
white: string;
|
|
||||||
gray: string;
|
|
||||||
grey: string;
|
|
||||||
|
|
||||||
bgBlack: string;
|
|
||||||
bgRed: string;
|
|
||||||
bgGreen: string;
|
|
||||||
bgYellow: string;
|
|
||||||
bgBlue: string;
|
|
||||||
bgMagenta: string;
|
|
||||||
bgCyan: string;
|
|
||||||
bgWhite: string;
|
|
||||||
|
|
||||||
reset: string;
|
|
||||||
bold: string;
|
|
||||||
dim: string;
|
|
||||||
italic: string;
|
|
||||||
underline: string;
|
|
||||||
inverse: string;
|
|
||||||
hidden: string;
|
|
||||||
strikethrough: string;
|
|
||||||
|
|
||||||
rainbow: string;
|
|
||||||
zebra: string;
|
|
||||||
america: string;
|
|
||||||
trap: string;
|
|
||||||
random: string;
|
|
||||||
}
|
|
2092
ts/typings/main/ambient/node/node.d.ts
vendored
2092
ts/typings/main/ambient/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
110
ts/typings/main/ambient/vinyl/vinyl.d.ts
vendored
110
ts/typings/main/ambient/vinyl/vinyl.d.ts
vendored
@ -1,110 +0,0 @@
|
|||||||
// Compiled using typings@0.6.3
|
|
||||||
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/78d36dd49b6b55b9fdfe61776a12bf05c8b07777/vinyl/vinyl.d.ts
|
|
||||||
// Type definitions for vinyl 0.4.3
|
|
||||||
// Project: https://github.com/wearefractal/vinyl
|
|
||||||
// Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao>
|
|
||||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
|
||||||
|
|
||||||
|
|
||||||
declare module 'vinyl' {
|
|
||||||
|
|
||||||
import fs = require('fs');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A virtual file format.
|
|
||||||
*/
|
|
||||||
class File {
|
|
||||||
constructor(options?: {
|
|
||||||
/**
|
|
||||||
* Default: process.cwd()
|
|
||||||
*/
|
|
||||||
cwd?: string;
|
|
||||||
/**
|
|
||||||
* Used for relative pathing. Typically where a glob starts.
|
|
||||||
*/
|
|
||||||
base?: string;
|
|
||||||
/**
|
|
||||||
* Full path to the file.
|
|
||||||
*/
|
|
||||||
path?: string;
|
|
||||||
/**
|
|
||||||
* Path history. Has no effect if options.path is passed.
|
|
||||||
*/
|
|
||||||
history?: string[];
|
|
||||||
/**
|
|
||||||
* The result of an fs.stat call. See fs.Stats for more information.
|
|
||||||
*/
|
|
||||||
stat?: fs.Stats;
|
|
||||||
/**
|
|
||||||
* File contents.
|
|
||||||
* Type: Buffer, Stream, or null
|
|
||||||
*/
|
|
||||||
contents?: Buffer | NodeJS.ReadWriteStream;
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default: process.cwd()
|
|
||||||
*/
|
|
||||||
public cwd: string;
|
|
||||||
/**
|
|
||||||
* Used for relative pathing. Typically where a glob starts.
|
|
||||||
*/
|
|
||||||
public base: string;
|
|
||||||
/**
|
|
||||||
* Full path to the file.
|
|
||||||
*/
|
|
||||||
public path: string;
|
|
||||||
public stat: fs.Stats;
|
|
||||||
/**
|
|
||||||
* Type: Buffer|Stream|null (Default: null)
|
|
||||||
*/
|
|
||||||
public contents: Buffer | NodeJS.ReadableStream;
|
|
||||||
/**
|
|
||||||
* Returns path.relative for the file base and file path.
|
|
||||||
* Example:
|
|
||||||
* var file = new File({
|
|
||||||
* cwd: "/",
|
|
||||||
* base: "/test/",
|
|
||||||
* path: "/test/file.js"
|
|
||||||
* });
|
|
||||||
* console.log(file.relative); // file.js
|
|
||||||
*/
|
|
||||||
public relative: string;
|
|
||||||
|
|
||||||
public isBuffer(): boolean;
|
|
||||||
|
|
||||||
public isStream(): boolean;
|
|
||||||
|
|
||||||
public isNull(): boolean;
|
|
||||||
|
|
||||||
public isDirectory(): boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.
|
|
||||||
*/
|
|
||||||
public clone(opts?: { contents?: boolean }): File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If file.contents is a Buffer, it will write it to the stream.
|
|
||||||
* If file.contents is a Stream, it will pipe it to the stream.
|
|
||||||
* If file.contents is null, it will do nothing.
|
|
||||||
*/
|
|
||||||
public pipe<T extends NodeJS.ReadWriteStream>(
|
|
||||||
stream: T,
|
|
||||||
opts?: {
|
|
||||||
/**
|
|
||||||
* If false, the destination stream will not be ended (same as node core).
|
|
||||||
*/
|
|
||||||
end?: boolean;
|
|
||||||
}
|
|
||||||
): T;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a pretty String interpretation of the File. Useful for console.log.
|
|
||||||
*/
|
|
||||||
public inspect(): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export = File;
|
|
||||||
|
|
||||||
}
|
|
Reference in New Issue
Block a user