Compare commits

...

122 Commits

Author SHA1 Message Date
372d2605bb 5.3.25 2016-07-19 20:31:56 +02:00
2ecf6c00b8 fix assets management 2016-07-19 20:31:49 +02:00
2f3d8cecd3 improve README 2016-07-19 00:28:18 +02:00
54bbab232e 5.3.24 2016-07-19 00:25:37 +02:00
380407b5e8 improve README 2016-07-19 00:25:31 +02:00
2a5583946c 5.3.23 2016-07-18 19:06:04 +02:00
80e36a34ee now using initial cwd for writing coverage reports 2016-07-18 19:06:00 +02:00
1f90f4abff 5.3.22 2016-07-17 17:13:53 +02:00
3c7f5f1e2d now using npmextra 2016-07-17 17:13:47 +02:00
8104609306 5.3.21 2016-07-16 23:33:14 +02:00
a3077f7800 improve README 2016-07-16 23:33:10 +02:00
c947121243 5.3.20 2016-07-16 20:54:57 +02:00
4b3f0649fa now much faster due to skipping html coverage report 2016-07-16 20:54:52 +02:00
523c62530f 5.3.19 2016-07-16 20:14:47 +02:00
aa57617fc7 another fix 2016-07-16 20:14:43 +02:00
ef89a33dfc 5.3.18 2016-07-16 19:23:37 +02:00
474a730a09 another fix 2016-07-16 19:23:34 +02:00
e3b029c240 5.3.17 2016-07-16 19:08:23 +02:00
290824190d fix dependency 2016-07-16 19:08:20 +02:00
923d78caab 5.3.16 2016-07-16 19:05:17 +02:00
6587b74a23 now using better babel config 2016-07-16 19:05:12 +02:00
aa0a35f258 5.3.15 2016-07-15 19:27:56 +02:00
09b8809ede fix test 2016-07-15 19:27:53 +02:00
e25566490b 5.3.14 2016-07-15 18:18:14 +02:00
3ed7473066 fix istanbul 2016-07-15 18:18:11 +02:00
1202a68b01 5.3.13 2016-07-15 12:22:29 +02:00
c67d43e16d prevent typedoc from causing build fail 2016-07-15 12:22:19 +02:00
df74769533 5.3.12 2016-07-15 11:52:00 +02:00
5aef714497 now fully ES6 2016-07-15 11:51:55 +02:00
24701afcb2 now using typedoc 2016-07-15 00:38:41 +02:00
cbfbd4ee67 restructure 2016-07-14 13:21:07 +02:00
6df449394d 5.3.11 2016-07-14 13:08:48 +02:00
27b6119bbb improve README 2016-07-14 13:08:43 +02:00
b22abef889 5.3.10 2016-07-14 13:04:11 +02:00
4d8a7a4202 Merge branch 'master' of gitlab.com:pushrocks/npmts 2016-07-14 13:03:54 +02:00
72bc08e973 5.3.9 2016-07-14 13:03:09 +02:00
430f636ae4 now using EsDoc, closes #2 2016-07-14 13:02:58 +02:00
bbc8f13ecf update docker link in README 2016-07-11 15:50:39 +02:00
a01f07f62c improve README 2016-07-11 14:46:31 +02:00
36316e63b2 5.3.9 2016-07-11 14:42:43 +02:00
5c5e88c226 further improve README 2016-07-11 14:42:36 +02:00
af968f65df update README 2016-07-11 13:46:44 +02:00
f0cc2f4cd6 5.3.8 2016-07-08 04:00:56 +02:00
f167226830 update sourcemap handling 2016-07-08 04:00:52 +02:00
3e49b365b6 small fix 2016-07-01 05:58:51 +02:00
c833374fdd 5.3.7 2016-07-01 05:44:37 +02:00
778f057d87 fix 2016-07-01 05:44:34 +02:00
8f57bf4dd5 remove debug 2016-07-01 05:25:49 +02:00
5a9f07002f 5.3.6 2016-07-01 05:19:19 +02:00
ca5ff20107 remove @types/gulp 2016-07-01 05:17:58 +02:00
a406ff648a fix npm variant 2016-07-01 05:06:11 +02:00
dab1f8514b 5.3.5 2016-07-01 04:50:26 +02:00
b80c1f9090 ready for primetime 2016-07-01 04:50:23 +02:00
fcd2616a3c recompile 2016-07-01 02:30:16 +02:00
1723193d27 integrate tsn and clean up 2016-07-01 02:28:34 +02:00
88cd04d0e2 prepare switch to tns 2016-06-30 03:17:24 +02:00
c4faa56d0d 5.3.4 2016-06-16 03:24:06 +02:00
20ad0d0b38 --notest now working 2016-06-16 03:24:01 +02:00
5221d3ee84 5.3.3 2016-06-16 03:02:37 +02:00
1f50f54fe9 now has --notest option 2016-06-16 03:02:33 +02:00
12199a668e 5.3.2 2016-06-12 04:32:00 +02:00
82df431adf improve README 2016-06-12 04:31:43 +02:00
71f0a9d37f 5.3.1 2016-06-12 00:45:49 +02:00
5f16cdd830 now printing font all right 2016-06-12 00:45:33 +02:00
966cb88c82 5.3.0 2016-06-10 06:14:18 +02:00
7f4d72f0d6 ready for npmts-g 2016-06-10 06:14:12 +02:00
3df47307a3 update gitlab ci.yml 2016-06-10 00:55:29 +02:00
e3b84af278 now stating npmts version 2016-06-10 00:53:30 +02:00
a6c4a99d82 update dependencies 2016-06-10 00:13:40 +02:00
8d506f8220 5.2.5 2016-06-07 09:03:03 +02:00
bd9ed5feb5 update gitlab ci yml 2016-06-07 09:02:58 +02:00
ec28c660dc 5.2.4 2016-06-07 08:56:27 +02:00
9f4299e52a update gitlab ci yml 2016-06-07 08:56:21 +02:00
73c583409e 5.2.3 2016-06-07 08:53:55 +02:00
f8c86f1871 small fix 2016-06-07 08:53:47 +02:00
67130ec2b6 5.2.2 2016-06-07 08:49:28 +02:00
48fa9d205a now compiling Tests seperately 2016-06-07 08:49:22 +02:00
3070584642 pages now publishing for tags 2016-06-03 16:57:03 +02:00
a71ffb2415 5.2.1 2016-06-03 16:48:58 +02:00
dc2be85236 add legacy test 2016-06-03 16:46:10 +02:00
964e1ce9ac 5.2.0 2016-06-03 16:43:56 +02:00
fba6e3d4c5 remove codecov 2016-06-03 16:43:46 +02:00
7df51bad07 Merge branch 'master' of gitlab.com:pushrocks/npmts 2016-06-02 13:11:14 +02:00
5c7af1e59f 5.1.20 2016-06-02 13:09:28 +02:00
e72f7fe5c6 Update .gitlab-ci.yml 2016-05-31 17:04:35 +00:00
da48b987ba update gitlab ci yml 2016-05-30 07:49:41 +02:00
9eabac7022 update gitlab yml 2016-05-30 07:30:01 +02:00
00683fbab1 fix gitlab.yml 2016-05-30 07:16:30 +02:00
3434bbf815 add pages to gitlab.yml 2016-05-30 07:05:17 +02:00
85ac242627 5.1.19 2016-05-30 05:44:40 +02:00
9b71872d12 Merge branch 'master' of gitlab.com:pushrocks/npmts 2016-05-30 05:44:21 +02:00
281595f8c8 update gitlab ci and use npmci 2016-05-30 05:42:24 +02:00
83f03994a9 Add contribution guide 2016-05-29 19:24:59 +00:00
01837f8420 Add changelog 2016-05-29 19:23:11 +00:00
b5735e3721 update .gitlab-ci.yml 2016-05-29 21:04:44 +02:00
0dc45f1414 improved GitLab compatibility 2016-05-29 20:56:53 +02:00
9d1c3f7457 disable codecov upload for now 2016-05-29 09:58:21 +02:00
017279730a Update README.md 2016-05-27 12:44:15 +00:00
0b50b14146 5.1.18 2016-05-27 01:00:25 +02:00
dfa27c0604 fix package.json 2016-05-27 01:00:19 +02:00
19e839a282 add .npmignore 2016-05-27 00:59:17 +02:00
647e2ec886 5.1.17 2016-05-26 23:56:02 +02:00
4e267850bf update repo URL 2016-05-26 23:55:57 +02:00
a52f6a9e9b 5.1.16 2016-05-26 23:34:00 +02:00
23b0ee1472 update gitlab.yml 2016-05-26 23:33:34 +02:00
c4d58b047c fix doPublish error 2016-05-26 22:53:59 +02:00
403b530a60 update ci-yml 2016-05-26 22:45:40 +02:00
7d6caaafce fix gitlab ci 2016-05-26 22:41:06 +02:00
8f47b95220 update ci 2016-05-26 22:38:23 +02:00
375d5cdfcc update ci yml 2016-05-26 22:37:13 +02:00
a3b1391b86 update gitlab ci 2016-05-26 21:21:35 +02:00
d2f5a81cfb update gitlab ci 2016-05-26 21:19:41 +02:00
2bc2d11a2d add gitlab ci 2016-05-26 21:18:14 +02:00
ecf0666103 5.1.15 2016-05-25 06:59:39 +02:00
ad05144bba update smartstring 2016-05-25 06:59:33 +02:00
1e77aba991 5.1.14 2016-05-25 05:24:05 +02:00
bb6c07845c update to typings-global 2016-05-25 05:23:48 +02:00
079b049a10 update dependencies 2016-05-25 05:14:56 +02:00
94f48afbbd 5.1.13 2016-05-23 05:34:30 +02:00
944e9b227c deactivate typings clean for now until nodehash is implemented 2016-05-23 05:34:25 +02:00
b83aaf4abf 5.1.12 2016-05-23 05:21:35 +02:00
51a1dd0b1d now uses latest early module 2016-05-23 05:21:28 +02:00
77 changed files with 673 additions and 882 deletions

11
.gitignore vendored
View File

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

47
.gitlab-ci.yml Normal file
View File

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

View File

@ -1,6 +1,6 @@
.idea/
support
compile
compile/
coverage/
test/
docs/
examples

7
CHANGELOG Normal file
View 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
View File

@ -0,0 +1,4 @@
# Contribution Guide
This module is developed on the fabulous GitLab.com:
https://gitlab.com/pushrocks/npmts

105
README.md
View File

@ -1,9 +1,8 @@
# npmts
Write npm modules with TypeScript without hassle.
Write npm modules with TypeScript without hassle. TypeScript ready. Fully ES6.
## Status
[![Build Status](https://travis-ci.org/pushrocks/npmts.svg?branch=master)](https://travis-ci.org/pushrocks/npmts)
[![Build status](https://ci.appveyor.com/api/projects/status/iiljwhhcvbuqyvq0?svg=true)](https://ci.appveyor.com/project/philkunz/npmts)
[![build status](https://gitlab.com/pushrocks/npmts/badges/master/build.svg)](https://gitlab.com/pushrocks/npmts/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/npmts.svg)](https://david-dm.org/pushrocks/npmts)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/npmts/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/npmts/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/npmts/badges/code.svg)](https://www.bithound.io/github/pushrocks/npmts)
@ -14,90 +13,67 @@ NPMTS is your friend when it comes to write, test, publish and document NPM modu
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/)
[hosttoday/ht-docker-node:npmts on Dockerhub](https://hub.docker.com/r/hosttoday/ht-docker-node/)
### Install
First install npmts as dev dependency:
First install npmts globally, then install the npmts-g locally.
> **npmts-g* checks if the global version of npmts suffices the modules requirements.
If not it installs npmts locally in the right version during npm install.
```sh
npm install npmts --save-dev
npm install npmts -g # installs npmts globally
npm install npmts-g --save-dev # installs npmts-g checking tool as devDependency
```
Then use it in package.json's script section to trigger a build:
Then add it to your package.json's script section to trigger a build:
```json
"scripts": {
"test": "npmts"
"test": "(npmts)"
}
```
### Default task execution order
1. Check config in ./npmts.json
1. Clean up from any previous builds (old js files)
1. Install typings
1. Transpile TypeScript with inline sourcemaps
1. Create Declaration Files
1. Create JsDoc Documentation
1. Instrumentalize created JavaScript files with istanbul
1. Run Tests
1. Create Coverage report
1. Upload Coverage reports to codecov.io (Tests must pass, codecov.io must be activated, by default only triggers on travis)
1. Upload JsDoc Documentation to gh-pages branch on GitHub. (Tests must pass, requires GitHub Token)
1. **Config:** Check config in ./npmextra.json (Check out [npmextra](https://www.npmjs.com/package/npmextra))
1. **Clean:** Clean up from any previous builds (old js files)
1. **Transpile:** Transpile TypeScript with **inline sourcemaps** and **declaration files** to ES6
1. **Documentation:** Create TypeDoc Documentation from TypeScript files
1. **Test:** Babelify ES6 to ES5 on the fly, instrumentalize ES5 JavaScript with istanbul and run tests with Mocha.
#### npmts.json
the npmts.json is the main config file. You can use it to customize the behaviour of NPMTS.
### npmextra.json
the npmts section in npmtsextra.json can be used to configure npmts.
```json
{
"mode":"default",
"codecov":true,
"ts":{
"./customdir/*.ts":"./"
},
"docs": {
"publish":true,
"destination":"github"
},
"tsOptions":{
"declaration":false,
"target":"ES6"
},
"typings":[
"./ts/typings.json",
"./subts1/typings.json",
"./subts2/typings.json",
"./customdir/typings.json"
],
"typingsInclude":"auto",
"cli":true
"npmts":{
"mode":"default",
"ts":{
"./customdir/*.ts":"./"
},
"tsOptions":{
"declaration":false,
"target":"ES6"
},
"cli":true
}
}
```
| key | default value | description |
| --- | --- | --- |
| `"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 |
| `"mode"` | `"default"` | "default" will do some default stuff, "custom" only does what you specify |
| `"tsOptions"` | `{"target":"ES5", "declaration":"true"}` | specify options for tsc |
| `"typings"` | `["./ts/typings.json"]` | allows you to specify multiple locations for typings.json to install. This is needed for modules that do not yet bundle typings |
| `"cli"` | "false" | some modules are designed to be used from cli. If set to true NPMTS will create a cli.js that wires you dist files up for cli use. |
#### Typings
**npmts** looks for `./ts/typings.json` by default and installs any defined typings to `.ts/typings/`.
> Note: You can reference the typings files in any of your TypeScript code with a
`/// <reference path="/some/path/main.d.ts">`
We are currently working on a "typingsInclude" option, that will autoload any typings during compilation.
tsconfig is NOT supported, since it would render this module useless
#### TypeScript
### 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
### Declaration files
**npmts** also creates an `./dist/index.d.ts` declaration file by default.
You can reference it in your package.json like this.
@ -110,24 +86,29 @@ 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
## Some notes:
#### Typings for third party modules that do not bundle declaration files
NPMTS does no longer supports typings.json. Instead use the new TypeScript 2.x approach to typings using the @types/ npm scope.
#### 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)
* [gulp-browser](https://www.npmjs.com/package/gulp-browser)
> We will add more options over time.
## Tips and tricks:
* Use [npmts-g](https://www.npmjs.com/package/npmts-g) to use globally installed npmts and install npmts locally if no global npmts is available.
* Use [npmpage](https://www.npmjs.com/package/npmpage) to create a webpage from coverage reports and TypeDoc for the module
* Use [hosttoday/ht-docker-node:npmts](https://hub.docker.com/r/hosttoday/ht-docker-node/) for speedy CI builds
* Use [npmdocker](https://www.npmjs.com/package/npmdocker) for running tests consistently with docker.
## About the authors:
[![Project Phase](https://mediaserve.lossless.digital/lossless.com/img/createdby_github.svg)](https://lossless.com/)

View File

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

View File

@ -1,49 +0,0 @@
// import gulp
var plugins = {
beautylog: require("beautylog"),
gulp: require("gulp"),
g:{
typescript: require("gulp-typescript"),
typings:require("gulp-typings")
},
mergeStream: require("merge2"),
path: require("path")
};
paths = {
packageBase: plugins.path.resolve(
plugins.path.join(__dirname,"../")
)
};
plugins.beautylog.log('now compiling NPMTS');
plugins.gulp.task("typings",function(){
var stream = plugins.gulp.src(plugins.path.join(paths.packageBase,"ts/typings.json"))
.pipe(plugins.g.typings());
return stream;
});
plugins.gulp.task("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.gulp.start.apply(plugins.gulp, ['default']);

1
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
import "typings-global";

32
dist/index.js vendored
View File

@ -1,14 +1,28 @@
"use strict";
/// <reference path="./typings/index.d.ts" />
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();
plugins.beautylog.figletSync("NPMTS");
try {
npmts_promisechain_1.promisechain();
}
catch (err) {
console.log(err);
}
early.stop()
.then(function () {
var npmtsProjectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.npmtsPackageRoot);
var npmtsCli = new plugins.smartcli.Smartcli();
npmtsCli.standardTask()
.then(function (argvArg) {
plugins.beautylog.figletSync("NPMTS");
plugins.beautylog.info("npmts version: " + npmtsProjectInfo.version);
try {
npmts_promisechain_1.promisechain(argvArg);
}
catch (err) {
console.log(err);
}
});
npmtsCli.addVersion(npmtsProjectInfo.version);
npmtsCli.startParse();
});

4
dist/npmts.assets.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare var run: (configArg: any) => plugins.Q.Promise<{}>;

View File

@ -1,5 +1,5 @@
"use strict";
/// <reference path="./typings/index.d.ts" />
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
@ -8,11 +8,12 @@ exports.run = function (configArg) {
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.smartfile.fs.copySync(plugins.path.join(paths.npmtsAssetsDir, "cli.js"), plugins.path.join(paths.distDir, "cli.js"));
plugins.beautylog.ok("installed CLI assets!");
done.resolve(config);
}
else {
plugins.beautylog.ok("No additional assets required!");
done.resolve(config);
}
return done.promise;

4
dist/npmts.clean.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

12
dist/npmts.clean.js vendored
View File

@ -1,15 +1,21 @@
"use strict";
/// <reference path="./typings/index.d.ts" />
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);
return plugins.smartfile.fs.remove(paths.distDir);
};
var removeTypings = function () {
var done = plugins.Q.defer();
npmts_promisechain_1.npmtsOra.text("cleaning " + "typings".yellow + " folder");
return plugins.smartfile.fsaction.remove(paths.typingsDir);
if (false) {
}
else {
done.resolve();
}
return done.promise;
};
exports.run = function (configArg) {
npmts_promisechain_1.npmtsOra.text("cleaning up from previous builds...");

1
dist/npmts.cli.js vendored
View File

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

4
dist/npmts.compile.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

1
dist/npmts.compile.helpers.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare let checkOutputPath: (tsArrayArg: any, keyArg: any) => boolean;

View File

@ -1,12 +1,12 @@
"use strict";
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var outputPathIsDir = function (configArg, keyArg) {
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, configArg.ts[keyArg]));
var outputPathIsDir = function (tsArrayArg, keyArg) {
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, tsArrayArg[keyArg]));
};
exports.checkOutputPath = function (configArg, keyArg) {
if (!outputPathIsDir(configArg, keyArg)) {
plugins.beautylog.warn("Skipping " + keyArg + " because " + configArg.ts[keyArg] + " it is no directory!");
exports.checkOutputPath = function (tsArrayArg, keyArg) {
if (!outputPathIsDir(tsArrayArg, keyArg)) {
plugins.beautylog.warn("Skipping " + keyArg + " because " + tsArrayArg[keyArg] + " it is no directory!");
return false;
}
else {

102
dist/npmts.compile.js vendored
View File

@ -1,79 +1,57 @@
"use strict";
/// <reference path="./typings/index.d.ts" />
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 promiseArray = [];
var compileTs = function (tsFileArrayArg, tsOptionsArg) {
if (tsOptionsArg === void 0) { tsOptionsArg = {}; }
var done = plugins.Q.defer();
var configTsLenght = Object.keys(configArg.ts).length;
if (configTsLenght == 0) {
plugins.beautylog.warn("No declaration files found... Are you sure you don't want them?");
done.resolve(configArg); //if there are no definition files, resolve...
}
var localCounter = 0;
for (var key in configArg.ts) {
var distPath = configArg.ts[key];
var stream = plugins.gulp.src(plugins.path.join(distPath, "**/*.d.ts"))
.pipe(plugins.g.replace(plugins.smartstring.typescript.regexReferencePath, ""))
.pipe(plugins.gulp.dest(distPath))
.pipe(plugins.g.gFunction(function () {
localCounter++;
if (localCounter == configTsLenght) {
plugins.beautylog.ok("made declaration files ready!");
done.resolve(configArg);
}
;
}, "atEnd"));
}
return done.promise;
};
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
npmts_promisechain_1.npmtsOra.text("now compiling " + "TypeScript".yellow);
var moduleStream = plugins.merge2({ end: false });
/* -------------------------------------------------
* ----------- compile TypeScript --------------------------
* ----------------------------------------------- */
var tsOptionsDefault = {
declaration: true,
target: "ES5",
target: "ES6",
module: "commonjs"
};
/**
* merges default ts options with those found in npmts.json
*/
var tsOptions = function (keyArg) {
return plugins.lodashObject.assign(tsOptionsDefault, config.tsOptions);
return plugins.lodashObject.assign(tsOptionsDefault, tsOptionsArg);
};
for (var keyArg in config.ts) {
if (helpers.checkOutputPath(config, keyArg)) {
var tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"])
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
.pipe(plugins.g.typescript(tsOptions(keyArg)));
var jsStream = tsStream.js
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
.pipe(plugins.gulp.dest(config.ts[keyArg]));
var declarationStream = tsStream.dts
.pipe(plugins.gulp.dest(config.ts[keyArg]));
moduleStream.add(tsStream, jsStream, declarationStream);
}
}
moduleStream.on("queueDrain", function () {
moduleStream.on("finish", function () {
plugins.beautylog.ok("compiled TypeScript!");
definitionHandler(config)
.then(function () {
done.resolve(config);
var _loop_1 = function(keyArg) {
plugins.beautylog.info("TypeScript assignment: transpile from " + keyArg.blue + " to " + tsFileArrayArg[keyArg].blue);
if (helpers.checkOutputPath(tsFileArrayArg, keyArg)) {
var filesReadPromise = plugins.smartfile.fs.listFileTree(process.cwd(), keyArg)
.then(function (filesToConvertArg) {
var filesToConvertAbsolute = plugins.smartpath.transform.toAbsolute(filesToConvertArg, process.cwd());
var destDir = plugins.smartpath.transform.toAbsolute(tsFileArrayArg[keyArg], process.cwd());
var filesCompiledPromise = plugins.tsn.compile(filesToConvertAbsolute, destDir);
promiseArray.push(filesCompiledPromise);
});
});
moduleStream.end();
});
/*==================== END TS Compilation =====================*/
promiseArray.push(filesReadPromise);
}
};
for (var keyArg in tsFileArrayArg) {
_loop_1(keyArg);
}
;
plugins.Q.all(promiseArray)
.then(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 () {
plugins.beautylog.ok("compiled main TypeScript!");
plugins.beautylog.log("now compiling tests!");
return compileTs(config.testTs);
})
.then(function () {
plugins.beautylog.ok("compiled all TypeScript!");
done.resolve(config);
});
return done.promise;
};

4
dist/npmts.configfile.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare var run: (argvArg: any) => plugins.Q.Promise<{}>;

View File

@ -1,31 +1,35 @@
"use strict";
/// <reference path="./typings/index.d.ts" />
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
exports.run = function () {
var npmts_promisechain_1 = require("./npmts.promisechain");
exports.run = function (argvArg) {
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);
npmts_promisechain_1.npmtsOra.text("looking for npmextra.json");
var defaultConfig = {
mode: "default",
notest: false
};
if (argvArg.notest) {
defaultConfig.notest = true;
}
;
var config = plugins.npmextra.dataFor({
toolName: "npmts",
defaultSettings: defaultConfig,
cwd: paths.cwd
});
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);
}
;
done.resolve(config);
return done.promise;
};

21
dist/npmts.install.js vendored
View File

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

56
dist/npmts.jsdoc.js vendored
View File

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

5
dist/npmts.options.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let isCi: () => any;
export declare var run: (configArg: any) => plugins.Q.Promise<{}>;

27
dist/npmts.options.js vendored
View File

@ -1,18 +1,10 @@
"use strict";
/// <reference path="./typings/index.d.ts" />
require("typings-global");
var plugins = require("./npmts.plugins");
var npmts_promisechain_1 = require("./npmts.promisechain");
exports.isCi = function () {
return plugins.smartci.check.isCi();
};
exports.isRelease = function () {
return plugins.smartci.check.isCi()
&& plugins.smartci.check.isTaggedCommit();
};
exports.doPublish = function () {
return exports.isRelease()
&& plugins.smartci.get.subJobNumber() == 1;
};
exports.run = function (configArg) {
var done = plugins.Q.defer();
var config = configArg;
@ -24,28 +16,21 @@ exports.run = function (configArg) {
];
config.ts = (_a = {},
_a["./ts/**/*.ts"] = "./dist/",
_a["./test/test.ts"] = "./test/",
_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 = {};
// handle state of current build
exports.isRelease() ? plugins.beautylog.info("All right: This is a RELEASE build!")
: plugins.beautylog.info("NOT A RELEASE build!");
exports.isRelease() && exports.doPublish() ? plugins.beautylog.info("All right: This is the first subBuild, so this one publishes COVERAGE + DOCS when tests succeed!")
: plugins.beautylog.info("We are not publishing anything!");
// handle coveralls
config.codecov ? void (0) : config.codecov = true;
exports.isCi() ? void (0) : config.codecov = false;
config.coverageTreshold ? void (0) : config.coverageTreshold = 70;
// handle docs
config.docs ? void (0) : config.docs = {};
config.docs.publish ? void (0) : config.docs.publish = false;
exports.doPublish() ? void (0) : config.docs.publish = false;
plugins.beautylog.ok("build options are ready!");
done.resolve(config);
return done.promise;
var _a;
var _a, _b;
};

12
dist/npmts.paths.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
import "typings-global";
export declare let npmtsPackageRoot: string;
export declare let cwd: string;
export declare let tsDir: string;
export declare let distDir: string;
export declare let docsDir: string;
export declare let testDir: string;
export declare let typingsDir: string;
export declare let coverageDir: string;
export declare let npmtsAssetsDir: string;
export declare let indexTS: string;
export declare let testTS: string;

7
dist/npmts.paths.js vendored
View File

@ -1,7 +1,10 @@
"use strict";
/// <reference path="./typings/index.d.ts" />
require("typings-global");
var plugins = require("./npmts.plugins");
exports.cwd = plugins.smartcli.get.cwd().path;
//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/");

28
dist/npmts.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
import "typings-global";
export import beautylog = require("beautylog");
export declare let gulp: any;
export declare let g: {
babel: any;
istanbul: any;
gFunction: any;
injectModules: any;
mocha: any;
replace: any;
sourcemaps: any;
typedoc: any;
};
export declare let lodashObject: any;
export import npmextra = require("npmextra");
export import projectinfo = require("projectinfo");
export import path = require("path");
export import Q = require("q");
export import shelljs = require("shelljs");
export declare let smartci: any;
export import smartcli = require("smartcli");
export declare let smartcov: any;
export import smartenv = require("smartenv");
export import smartfile = require("smartfile");
export import smartpath = require("smartpath");
export import smartstring = require("smartstring");
export declare let sourceMapSupport: any;
export import tsn = require("tsn");

15
dist/npmts.plugins.js vendored
View File

@ -1,21 +1,19 @@
"use strict";
/// <reference path="./typings/index.d.ts" />
require("typings-global");
exports.beautylog = require("beautylog");
exports.fs = require("fs-extra");
exports.gulp = require("gulp");
exports.g = {
codecov: require("gulp-codecov"),
gFunction: require("gulp-function"),
babel: require("gulp-babel"),
istanbul: require("gulp-istanbul"),
jsdoc3: require("gulp-jsdoc3"),
gFunction: require("gulp-function"),
injectModules: require("gulp-inject-modules"),
mocha: require("gulp-mocha"),
replace: require("gulp-replace"),
sourcemaps: require("gulp-sourcemaps"),
typescript: require("gulp-typescript"),
typings: require("gulp-typings")
typedoc: require("gulp-typedoc")
};
exports.lodashObject = require('lodash/fp/object');
exports.merge2 = require("merge2");
exports.npmextra = require("npmextra");
exports.projectinfo = require("projectinfo");
exports.path = require("path");
exports.Q = require("q");
@ -28,3 +26,4 @@ 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
exports.tsn = require("tsn");

6
dist/npmts.promisechain.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
import { Ora } from "beautylog";
export declare let npmtsOra: Ora;
export declare let promisechain: (argvArg: any) => plugins.Q.Promise<{}>;

View File

@ -1,28 +1,24 @@
"use strict";
/// <reference path="./typings/index.d.ts" />
require("typings-global");
var plugins = require("./npmts.plugins");
exports.npmtsOra = new plugins.beautylog.Ora("setting up TaskChain", "cyan");
exports.npmtsOra.start();
var NpmtsAssets = require("./npmts.assets");
var NpmtsClean = require("./npmts.clean");
var NpmtsCompile = require("./npmts.compile");
var NpmtsConfigFile = require("./npmts.configfile");
var NpmtsInstall = require("./npmts.install");
var NpmtsJsdoc = require("./npmts.jsdoc");
var NpmtsTypeDoc = require("./npmts.typedoc");
var NpmtsOptions = require("./npmts.options");
var NpmtsPublish = require("./npmts.publish");
var NpmtsTests = require("./npmts.tests");
exports.promisechain = function () {
exports.promisechain = function (argvArg) {
var done = plugins.Q.defer();
NpmtsConfigFile.run()
exports.npmtsOra.start();
NpmtsConfigFile.run(argvArg)
.then(NpmtsOptions.run)
.then(NpmtsClean.run)
.then(NpmtsInstall.run)
.then(NpmtsCompile.run)
.then(NpmtsAssets.run)
.then(NpmtsJsdoc.run)
.then(NpmtsTypeDoc.run)
.then(NpmtsTests.run)
.then(NpmtsPublish.run)
.then(function (configArg) {
var shipString = "" +
"\n" +

15
dist/npmts.publish.js vendored
View File

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

4
dist/npmts.tests.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

90
dist/npmts.tests.js vendored
View File

@ -1,49 +1,44 @@
"use strict";
/// <reference path="./typings/index.d.ts" />
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
exports.publishCoverage = function (configArg) {
var done = plugins.Q.defer();
plugins.beautylog.log("now uploading coverage data to codecov.io");
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
.pipe(plugins.g.codecov())
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("Coverage data has been uploaded to codecov.io!");
done.resolve(configArg);
}, "atEnd"));
return done.promise;
};
/**
*
* @returns {*}
*/
var istanbul = function (configArg) {
npmts_promisechain_1.npmtsOra.text("Instrumentalizing transpiled JS...");
var done = plugins.Q.defer();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
.pipe(plugins.g.istanbul()) // Covering files
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!");
done.resolve(configArg);
}, "atEnd"));
return done.promise;
};
/**
*
* @returns {*}
*/
var mocha = function (configArg) {
var done = plugins.Q.defer();
npmts_promisechain_1.npmtsOra.text("Instrumentalizing and testing transpiled JS");
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"));
var done = plugins.Q.defer();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
.pipe(plugins.g.sourcemaps.init())
.pipe(plugins.g.babel({
presets: [
require.resolve("babel-preset-es2015")
]
}))
.pipe(plugins.g.istanbul({}))
.pipe(plugins.g.sourcemaps.write())
.pipe(plugins.g.injectModules())
.on("finish", function () {
plugins.gulp.src([plugins.path.join(paths.cwd, "test/test.js")])
.pipe(plugins.g.babel({
presets: [
plugins.path.join(paths.npmtsPackageRoot, "node_modules/babel-preset-es2015/index.js")
]
}))
.pipe(plugins.g.injectModules())
.pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports({
dir: plugins.path.join(paths.cwd, "./coverage"),
reporters: ['lcovonly', 'json', 'text', 'text-summary']
}))
.pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("Tested!");
done.resolve(configArg);
}, "atEnd"));
});
return done.promise;
};
var coverage = function (configArg) {
@ -67,13 +62,20 @@ var coverage = function (configArg) {
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);
if (config.notest != true) {
npmts_promisechain_1.npmtsOra.text("now starting tests");
plugins.beautylog.log("-------------------------------------------------------\n" +
"*************************** TESTS: ***************************\n" +
"--------------------------------------------------------------");
mocha(config)
.then(coverage)
.then(function () {
done.resolve(config);
});
}
else {
npmts_promisechain_1.npmtsOra.end();
done.resolve(config);
}
return done.promise;
};

4
dist/npmts.typedoc.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="q" />
import "typings-global";
import plugins = require("./npmts.plugins");
export declare let run: (configArg: any) => plugins.Q.Promise<{}>;

35
dist/npmts.typedoc.js vendored Normal file
View File

@ -0,0 +1,35 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
var genTypeDoc = function (configArg) {
var done = plugins.Q.defer();
npmts_promisechain_1.npmtsOra.text("now generating " + "TypeDoc documentation".yellow);
plugins.beautylog.log("TypeDoc Output:");
plugins.gulp.src(plugins.path.join(paths.tsDir, "**/*.ts"))
.pipe(plugins.g.typedoc({
// TypeScript options (see typescript docs)
module: "commonjs",
target: "es6",
includeDeclarations: true,
// Output options (see typedoc docs)
out: paths.docsDir,
json: plugins.path.join(paths.docsDir, "file.json"),
// TypeDoc options (see typedoc docs)
name: "my-project",
//theme: "default",
ignoreCompilerErrors: true,
version: true,
}))
.pipe(plugins.g.gFunction(done.resolve, "atEnd"));
return done.promise;
};
exports.run = function (configArg) {
var done = plugins.Q.defer();
genTypeDoc(configArg)
.then(function () {
done.resolve(configArg);
});
return done.promise;
};

View File

@ -1,19 +1,22 @@
{
"name": "npmts",
"version": "5.1.11",
"description": "write npm modules with TypeScript",
"version": "5.3.25",
"description": "Write npm modules with TypeScript without hassle. TypeScript ready. Fully ES6.",
"main": "dist/index.js",
"bin": {
"npmts": "dist/cli.js"
},
"scripts": {
"test": "(npm run compile && npm run check)",
"check": "(cd ./test/assets && node ../../dist/index.js)",
"compile": "(cd compile && node compile.js)"
"test": "(npm run compile && npm run setupCheck && npm run check && npm run checkVersion && npm run checkNoTest)",
"compile": "(rm -rf test/ && rm -r dist/ && mkdir dist/ && tsc && cp assets/cli.js dist/ )",
"setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)",
"check": "(cd test && node ../dist/index.js)",
"checkVersion": "(cd test/ && node ../dist/index.js -v)",
"checkNoTest": "(cd test && node ../dist/index.js --notest)"
},
"repository": {
"type": "git",
"url": "git+https://github.com/pushrocks/npmts.git"
"url": "git+https://gitlab.com/pushrocks/npmts.git"
},
"keywords": [
"TypeScript",
@ -22,38 +25,44 @@
"author": "Lossless Digital UG (haftungsbeschraenkt)",
"license": "MIT",
"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": {
"beautylog": "5.0.5",
"early": "^1.0.7",
"fs-extra": "^0.30.0",
"@types/minimatch": "^2.0.28",
"@types/q": "^0.0.27",
"@types/shelljs": "^0.3.27",
"babel-preset-es2015": "^6.9.0",
"beautylog": "5.0.14",
"early": "^2.0.13",
"gulp": "3.9.1",
"gulp-codecov": "^2.0.1",
"gulp-babel": "^6.1.2",
"gulp-concat": "^2.6.0",
"gulp-function": "^1.3.1",
"gulp-function": "^1.3.6",
"gulp-if": "^2.0.1",
"gulp-istanbul": "^0.10.4",
"gulp-jsdoc3": "^0.2.1",
"gulp-inject-modules": "^1.0.0",
"gulp-istanbul": "^1.0.0",
"gulp-mocha": "^2.2.0",
"gulp-replace": "^0.5.4",
"gulp-sourcemaps": "^2.0.0-alpha",
"gulp-typescript": "2.13.4",
"gulp-typings": "2.0.0",
"lodash": "^4.12.0",
"merge2": "1.0.2",
"projectinfo": "1.0.1",
"gulp-sourcemaps": "^1.6.0",
"gulp-typedoc": "^2.0.0",
"lodash": "^4.13.1",
"npmextra": "^1.0.7",
"projectinfo": "1.0.3",
"q": "^1.4.1",
"shelljs": "^0.7.0",
"smartci": "0.0.1",
"smartcli": "0.0.11",
"smartcli": "1.0.4",
"smartcov": "0.0.6",
"smartenv": "1.2.5",
"smartfile": "3.0.7",
"smartpath": "3.2.1",
"smartstring": "^1.0.3",
"source-map-support": "^0.4.0"
"smartfile": "4.0.10",
"smartpath": "3.2.2",
"smartstring": "^2.0.14",
"source-map-support": "^0.4.2",
"tsn": "^1.0.7",
"typedoc": "^0.4.4",
"typescript": "^2.0.0-dev.20160630",
"typings-global": "*"
},
"devDependencies": {}
}

View File

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

View File

@ -1,2 +0,0 @@
var hello = "hello";
//# sourceMappingURL=custom.js.map

View File

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

View File

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

View File

@ -1,2 +0,0 @@
var something = "something";
//# sourceMappingURL=tsfile1.js.map

View File

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

View File

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

View File

@ -1,7 +0,0 @@
{
"ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
}
}

View File

@ -1,3 +0,0 @@
declare let testplugin: {
logSomething: () => void;
};

View File

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

View File

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

View File

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

View File

@ -1,7 +0,0 @@
{
"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"
}
}

Binary file not shown.

View File

@ -1 +0,0 @@
declare var testplugin: any;

View File

@ -1,11 +0,0 @@
/// <reference path="../ts/typings/index.d.ts" />
var testplugin = require("../dist/index.js");
describe("testplugins", function () {
describe(".logSomething", function () {
it("should log something", function () {
testplugin.logSomething();
});
});
});
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsaURBQWlEO0FBQ2pELElBQUksVUFBVSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzdDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixFQUFFLENBQUMsc0JBQXNCLEVBQUM7WUFDdEIsVUFBVSxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQzdCLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvaW5kZXguZC50c1wiIC8+XHJcbnZhciB0ZXN0cGx1Z2luID0gcmVxdWlyZShcIi4uL2Rpc3QvaW5kZXguanNcIik7XHJcbmRlc2NyaWJlKFwidGVzdHBsdWdpbnNcIixmdW5jdGlvbigpe1xyXG4gICAgZGVzY3JpYmUoXCIubG9nU29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcclxuICAgICAgICBpdChcInNob3VsZCBsb2cgc29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcclxuICAgICAgICAgICAgdGVzdHBsdWdpbi5sb2dTb21ldGhpbmcoKVxyXG4gICAgICAgIH0pO1xyXG4gICAgfSk7XHJcbn0pOyJdfQ==

View File

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

View File

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

View File

@ -1,8 +0,0 @@
{
"ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
}
}

View File

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

View File

@ -1,8 +0,0 @@
{
"globalDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts",
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts"
}
}

View File

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

View File

@ -1,16 +1,30 @@
/// <reference path="./typings/index.d.ts" />
import "typings-global";
/* ================================================== *
Starting NPMTS main process.
* ================================================== */
import * as early from "early";
early.start("NPMTS");
import * as plugins from "./npmts.plugins"
import * as paths from "./npmts.paths";
import {promisechain} from "./npmts.promisechain";
early.stop();
early.stop()
.then(() => {
let npmtsProjectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.npmtsPackageRoot);
plugins.beautylog.figletSync("NPMTS");
try {
promisechain();
}
catch(err){
console.log(err);
}
let npmtsCli = new plugins.smartcli.Smartcli();
npmtsCli.standardTask()
.then((argvArg) => {
plugins.beautylog.figletSync("NPMTS");
plugins.beautylog.info("npmts version: " + npmtsProjectInfo.version);
try {
promisechain(argvArg);
}
catch(err){
console.log(err);
}
});
npmtsCli.addVersion(npmtsProjectInfo.version);
npmtsCli.startParse();
});

View File

@ -1,4 +1,4 @@
/// <reference path="./typings/index.d.ts" />
import "typings-global";
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
import {npmtsOra} from "./npmts.promisechain";
@ -8,10 +8,14 @@ export var run = function(configArg){
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.smartfile.fs.copySync(
plugins.path.join(paths.npmtsAssetsDir,"cli.js"),
plugins.path.join(paths.distDir,"cli.js")
);
plugins.beautylog.ok("installed CLI assets!");
done.resolve(config);
} else {
plugins.beautylog.ok("No additional assets required!")
done.resolve(config);
}
return done.promise;

View File

@ -1,16 +1,23 @@
/// <reference path="./typings/index.d.ts" />
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);
return plugins.smartfile.fs.remove(paths.distDir);
};
let removeTypings = function(){
let done = plugins.Q.defer();
npmtsOra.text("cleaning " + "typings".yellow + " folder");
return plugins.smartfile.fsaction.remove(paths.typingsDir);
if(false){
//plugins.smartfile.fsaction.remove(paths.typingsDir)
// .then(done.resolve);
} else {
done.resolve();
}
return done.promise;
};
export let run = function(configArg){

View File

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

View File

@ -1,13 +1,13 @@
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
let outputPathIsDir = function (configArg,keyArg) {
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, configArg.ts[keyArg]));
let outputPathIsDir = function (tsArrayArg,keyArg) {
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, tsArrayArg[keyArg]));
};
export let checkOutputPath = function(configArg,keyArg){
if(!outputPathIsDir(configArg,keyArg)) {
plugins.beautylog.warn("Skipping " + keyArg + " because " + configArg.ts[keyArg] + " it is no directory!")
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;

View File

@ -1,35 +1,43 @@
/// <reference path="./typings/index.d.ts" />
import "typings-global";
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
import helpers = require("./npmts.compile.helpers");
import {npmtsOra} from "./npmts.promisechain";
/**
* handles definition to make them fit for modular use
*/
let definitionHandler = function(configArg){
npmtsOra.text("now making declaration files ready");
let promiseArray = [];
let compileTs = (tsFileArrayArg:string[],tsOptionsArg = {}) => {
let done = plugins.Q.defer();
let configTsLenght = Object.keys(configArg.ts).length;
if(configTsLenght == 0) {
plugins.beautylog.warn("No declaration files found... Are you sure you don't want them?");
done.resolve(configArg); //if there are no definition files, resolve...
}
let localCounter = 0;
for (let key in configArg.ts){
let distPath = configArg.ts[key];
let stream = plugins.gulp.src(plugins.path.join(distPath,"**/*.d.ts"))
.pipe(plugins.g.replace(plugins.smartstring.typescript.regexReferencePath,""))
.pipe(plugins.gulp.dest(distPath))
.pipe(plugins.g.gFunction(function(){
localCounter++
if(localCounter == configTsLenght){
plugins.beautylog.ok("made declaration files ready!");
done.resolve(configArg)
};
},"atEnd"));
}
let tsOptionsDefault = {
declaration: true,
target: "ES6",
module: "commonjs"
};
/**
* 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) {
plugins.beautylog.info(`TypeScript assignment: transpile from ${keyArg.blue} to ${tsFileArrayArg[keyArg].blue}`);
if (helpers.checkOutputPath(tsFileArrayArg,keyArg)) {
let filesReadPromise = plugins.smartfile.fs.listFileTree(process.cwd(),keyArg)
.then((filesToConvertArg) => {
let filesToConvertAbsolute = plugins.smartpath.transform.toAbsolute(filesToConvertArg,process.cwd());
let destDir = plugins.smartpath.transform.toAbsolute(tsFileArrayArg[keyArg],process.cwd());
let filesCompiledPromise = plugins.tsn.compile(
filesToConvertAbsolute,
destDir
);
promiseArray.push(filesCompiledPromise);
});
promiseArray.push(filesReadPromise);
}
};
plugins.Q.all(promiseArray)
.then(done.resolve);
return done.promise;
}
@ -38,53 +46,16 @@ export let run = function (configArg) {
let done = plugins.Q.defer();
let config = configArg;
npmtsOra.text("now compiling " + "TypeScript".yellow);
let moduleStream = plugins.merge2({ end: false });
/* -------------------------------------------------
* ----------- compile TypeScript --------------------------
* ----------------------------------------------- */
let tsOptionsDefault = {
declaration: true,
target: "ES5",
module: "commonjs"
};
/**
* merges default ts options with those found in npmts.json
*/
let tsOptions = function (keyArg:string) {
return plugins.lodashObject.assign(tsOptionsDefault, config.tsOptions)
};
for (let keyArg in config.ts) {
if (helpers.checkOutputPath(config,keyArg)) {
let tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"])
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
.pipe(plugins.g.typescript(tsOptions(keyArg)));
let jsStream = tsStream.js
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
.pipe(plugins.gulp.dest(config.ts[keyArg]));
let declarationStream = tsStream.dts
.pipe(plugins.gulp.dest(config.ts[keyArg]));
moduleStream.add(tsStream,jsStream,declarationStream);
}
}
moduleStream.on("queueDrain", function () {
moduleStream.on("finish", function () {
plugins.beautylog.ok("compiled TypeScript!");
definitionHandler(config)
.then(function(){
done.resolve(config);
});
compileTs(config.ts,config.tsOptions)
.then(() => {
plugins.beautylog.ok("compiled main TypeScript!");
plugins.beautylog.log("now compiling tests!");
return compileTs(config.testTs);
})
.then(function () {
plugins.beautylog.ok("compiled all TypeScript!");
done.resolve(config);
});
moduleStream.end();
});
/*==================== END TS Compilation =====================*/
return done.promise;
};

View File

@ -1,27 +1,32 @@
/// <reference path="./typings/index.d.ts" />
import "typings-global";
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
export var run = function(){
var done = plugins.Q.defer();
var config:any = {};
var configPath = plugins.path.join(paths.cwd,"npmts.json");
if(plugins.smartfile.checks.fileExistsSync(configPath)){
plugins.beautylog.info("npmts.json".blue + " config file found!");
config = plugins.smartfile.local.toObjectSync(configPath);
switch (config.mode){
case "default":
case "custom":
plugins.beautylog.ok("mode is " + config.mode.yellow);
done.resolve(config);
break;
default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
};
} else {
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
config.mode = "default";
done.resolve(config);
import {npmtsOra} from "./npmts.promisechain";
export var run = function(argvArg){
let done = plugins.Q.defer();
npmtsOra.text("looking for npmextra.json");
let defaultConfig = {
mode: "default",
notest:false
};
if(argvArg.notest){
defaultConfig.notest = true;
};
let config = plugins.npmextra.dataFor({
toolName:"npmts",
defaultSettings:defaultConfig,
cwd:paths.cwd
});
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);
};
done.resolve(config);
return done.promise;
};

View File

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

View File

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

View File

@ -1,4 +1,4 @@
/// <reference path="./typings/index.d.ts" />
import "typings-global";
import plugins = require("./npmts.plugins");
import {npmtsOra} from "./npmts.promisechain";
@ -6,16 +6,6 @@ export let isCi = function(){
return plugins.smartci.check.isCi();
};
export let isRelease = function():boolean {
return plugins.smartci.check.isCi()
&& plugins.smartci.check.isTaggedCommit();
};
export let doPublish = function():boolean {
return isRelease()
&& plugins.smartci.get.subJobNumber() == 1;
};
export var run = function(configArg){
var done = plugins.Q.defer();
var config = configArg;
@ -28,7 +18,9 @@ export var run = function(configArg){
"./ts/typings.json"
];
config.ts = {
["./ts/**/*.ts"]: "./dist/",
["./ts/**/*.ts"]: "./dist/"
};
config.testTs = {
["./test/test.ts"]: "./test/"
};
config.test = ["./index.js"];
@ -37,23 +29,12 @@ export var run = function(configArg){
//check if config.tsOptions is available
config.tsOptions ? void(0) : config.tsOptions = {};
// handle state of current build
isRelease() ? plugins.beautylog.info("All right: This is a RELEASE build!")
: plugins.beautylog.info("NOT A RELEASE build!");
isRelease() && doPublish() ? plugins.beautylog.info("All right: This is the first subBuild, so this one publishes COVERAGE + DOCS when tests succeed!")
: plugins.beautylog.info("We are not publishing anything!");
// handle coveralls
config.codecov ? void(0) : config.codecov = true;
isCi() ? void(0) : config.codecov = false;
config.coverageTreshold ? void(0) : config.coverageTreshold = 70;
// handle docs
config.docs ? void(0) : config.docs = {};
config.docs.publish ? void(0) : config.docs.publish = false;
doPublish() ? void(0) : config.docs.publish = false;
plugins.beautylog.ok("build options are ready!");
done.resolve(config);

View File

@ -1,7 +1,12 @@
/// <reference path="./typings/index.d.ts" />
import "typings-global";
import plugins = require("./npmts.plugins");
export let cwd = plugins.smartcli.get.cwd().path;
//Npmts Paths
export let npmtsPackageRoot = plugins.path.join(__dirname,"../");
//Project paths
export let cwd = process.cwd();
//Directories
export let tsDir = plugins.path.join(cwd,"ts/");

View File

@ -1,30 +1,28 @@
/// <reference path="./typings/index.d.ts" />
import "typings-global";
export import beautylog = require("beautylog");
export let fs = require("fs-extra");
export let gulp = require("gulp");
export let g = {
codecov: require("gulp-codecov"),
gFunction: require("gulp-function"),
babel: require("gulp-babel"),
istanbul: require("gulp-istanbul"),
jsdoc3: require("gulp-jsdoc3"),
gFunction: require("gulp-function"),
injectModules: require("gulp-inject-modules"),
mocha: require("gulp-mocha"),
replace: require("gulp-replace"),
sourcemaps: require("gulp-sourcemaps"),
typescript: require("gulp-typescript"),
typings: require("gulp-typings")
typedoc: require("gulp-typedoc")
};
export let lodashObject = require('lodash/fp/object');
export let merge2 = require("merge2");
export let projectinfo = require("projectinfo");
export let path = require("path");
export let Q = require("q");
export let shelljs = require("shelljs");
export import npmextra = require("npmextra");
export import projectinfo = require("projectinfo");
export import path = require("path");
export import Q = require("q");
export import shelljs = require("shelljs");
export let smartci = require("smartci");
export let smartcli = require("smartcli");
export import smartcli = require("smartcli");
export let smartcov = require("smartcov");
export let smartenv = require("smartenv");
export let smartfile = require("smartfile");
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
export let sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing
export import tsn = require("tsn");

View File

@ -1,30 +1,27 @@
/// <reference path="./typings/index.d.ts" />
import "typings-global";
import plugins = require("./npmts.plugins");
import {Ora} from "beautylog"
export let npmtsOra = new plugins.beautylog.Ora("setting up TaskChain","cyan");
npmtsOra.start();
import NpmtsAssets = require("./npmts.assets");
import NpmtsClean = require("./npmts.clean");
import NpmtsCompile = require("./npmts.compile");
import NpmtsConfigFile = require("./npmts.configfile");
import NpmtsInstall = require("./npmts.install");
import NpmtsJsdoc = require("./npmts.jsdoc");
import NpmtsTypeDoc = require("./npmts.typedoc");
import NpmtsOptions = require("./npmts.options");
import NpmtsPublish = require("./npmts.publish");
import NpmtsTests = require("./npmts.tests");
export let promisechain = function(){
export let promisechain = function(argvArg){
let done = plugins.Q.defer();
NpmtsConfigFile.run()
npmtsOra.start();
NpmtsConfigFile.run(argvArg)
.then(NpmtsOptions.run)
.then(NpmtsClean.run)
.then(NpmtsInstall.run)
.then(NpmtsCompile.run)
.then(NpmtsAssets.run)
.then(NpmtsJsdoc.run)
.then(NpmtsTypeDoc.run)
.then(NpmtsTests.run)
.then(NpmtsPublish.run)
.then(function(configArg){
let shipString = "" +
"\n" +

View File

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

View File

@ -1,51 +1,45 @@
/// <reference path="./typings/index.d.ts" />
import "typings-global";
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
import {npmtsOra} from "./npmts.promisechain";
export let publishCoverage = function(configArg){
let done = plugins.Q.defer();
plugins.beautylog.log("now uploading coverage data to codecov.io");
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
.pipe(plugins.g.codecov())
.pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("Coverage data has been uploaded to codecov.io!");
done.resolve(configArg);
},"atEnd"));
return done.promise;
};
/**
*
* @returns {*}
*/
let istanbul = function (configArg) {
npmtsOra.text("Instrumentalizing transpiled JS...");
let done = plugins.Q.defer();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
.pipe(plugins.g.istanbul()) // Covering files
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
.pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("JS has been instrumentalized to get test code coverage!");
done.resolve(configArg);
},"atEnd"));
return done.promise;
};
/**
*
* @returns {*}
*/
let mocha = function (configArg) {
let done = plugins.Q.defer();
npmtsOra.text("Instrumentalizing and testing transpiled JS");
npmtsOra.end(); // end npmtsOra for tests.
let stream = plugins.gulp.src(["./test/test.js"])
.pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
.pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("Tests have passed!");
done.resolve(configArg);
},"atEnd"));
let done = plugins.Q.defer();
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
.pipe(plugins.g.sourcemaps.init())
.pipe(plugins.g.babel({
presets: [
require.resolve("babel-preset-es2015")
]
}))
.pipe(plugins.g.istanbul({
}))
.pipe(plugins.g.sourcemaps.write())
.pipe(plugins.g.injectModules())
.on("finish",function(){
plugins.gulp.src([plugins.path.join(paths.cwd,"test/test.js")])
.pipe(plugins.g.babel({
presets: [
plugins.path.join(paths.npmtsPackageRoot,"node_modules/babel-preset-es2015/index.js")
]
}))
.pipe(plugins.g.injectModules())
.pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports({
dir: plugins.path.join(paths.cwd,"./coverage"),
reporters: [ 'lcovonly', 'json', 'text', 'text-summary']
}))
.pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("Tested!");
done.resolve(configArg);
},"atEnd"));
});
return done.promise;
};
@ -74,17 +68,22 @@ let coverage = function(configArg){
export let run = function(configArg) {
let done = plugins.Q.defer();
let config = configArg;
if(config.notest != true){
npmtsOra.text("now starting tests");
plugins.beautylog.log(
"-------------------------------------------------------\n" +
"*************************** TESTS: ***************************\n" +
"--------------------------------------------------------------"
);
npmtsOra.text("now starting tests");
plugins.beautylog.log(
"-------------------------------------------------------\n" +
"*************************** TESTS: ***************************\n" +
"--------------------------------------------------------------"
);
istanbul(config)
.then(mocha)
.then(coverage)
.then(done.resolve);
mocha(config)
.then(coverage)
.then(() => {
done.resolve(config);
});
} else {
npmtsOra.end();
done.resolve(config);
}
return done.promise;
};

40
ts/npmts.typedoc.ts Normal file
View File

@ -0,0 +1,40 @@
import "typings-global";
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
import {npmtsOra} from "./npmts.promisechain";
let genTypeDoc = function(configArg){
let done = plugins.Q.defer();
npmtsOra.text("now generating " + "TypeDoc documentation".yellow);
plugins.beautylog.log("TypeDoc Output:");
plugins.gulp.src(plugins.path.join(paths.tsDir,"**/*.ts"))
.pipe(plugins.g.typedoc({
// TypeScript options (see typescript docs)
module: "commonjs",
target: "es6",
includeDeclarations: true,
// Output options (see typedoc docs)
out: paths.docsDir,
json: plugins.path.join(paths.docsDir,"file.json"),
// TypeDoc options (see typedoc docs)
name: "my-project",
//theme: "default",
ignoreCompilerErrors: true,
version: true,
}))
.pipe(plugins.g.gFunction(done.resolve,"atEnd"));
return done.promise;
};
export let run = function(configArg){
let done = plugins.Q.defer();
genTypeDoc(configArg)
.then(() => {
done.resolve(configArg);
});
return done.promise;
};

View File

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

8
tsconfig.json Normal file
View File

@ -0,0 +1,8 @@
{
"compilerOptions": {
"declaration": true,
"module": "commonjs",
"target": "ES5",
"outDir": "./dist/"
}
}