Compare commits
56 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
@ -1 +0,0 @@
|
|||||||
# README-dev
|
|
119
README.md
119
README.md
@ -6,9 +6,13 @@ Write npm modules with TypeScript without hassle.
|
|||||||
[](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.
|
||||||
|
|
||||||
|
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:
|
||||||
@ -29,18 +33,61 @@ Then use it in package.json's script section to trigger a build:
|
|||||||
|
|
||||||
**Execution order of tasks**
|
**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
|
||||||
|
the npmts.json is the main config file. You can use it to customize the behaviour of NPMTS.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mode":"default",
|
||||||
|
"ts":{
|
||||||
|
"./customdir/*.ts":"./"
|
||||||
|
},
|
||||||
|
"tsOptions":{
|
||||||
|
"declaration":false,
|
||||||
|
"target":"ES6"
|
||||||
|
},
|
||||||
|
"typings":[
|
||||||
|
"./ts/typings.json",
|
||||||
|
"./subts1/typings.json",
|
||||||
|
"./subts2/typings.json",
|
||||||
|
"./customdir/typings.json"
|
||||||
|
],
|
||||||
|
"typingsInclude":"auto",
|
||||||
|
"codecov":true,
|
||||||
|
"docs": {
|
||||||
|
"publish":true
|
||||||
|
},
|
||||||
|
"cli":true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| key | description |
|
||||||
|
| --- | --- |
|
||||||
|
| codecov | if true, coverage data will be uploaded to codecov when running on travis |
|
||||||
|
| docs | `{"publish":true, destination:"github"}` lets you control what happens with your module documentation |
|
||||||
|
| mode | "default" will do some defualt stuff, "custom" only does what you specify |
|
||||||
|
| tsOptions | specify options for tsc |
|
||||||
|
| | |
|
||||||
|
|
||||||
#### Typings
|
#### Typings
|
||||||
**npmts** looks for `./ts/typings.json` by default and installs any defined typings to `.ts/typings/`.
|
**npmts** looks for `./ts/typings.json` by default and installs any defined typings to `.ts/typings/`.
|
||||||
You can then reference the ./ts/typings/main.d.ts file in your TypeScript code.
|
|
||||||
|
> 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
|
by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
|
||||||
@ -49,49 +96,37 @@ by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
|
|||||||
Use commonjs module system for wiring up files.
|
Use commonjs module system for wiring up files.
|
||||||
|
|
||||||
#### Declaration files
|
#### Declaration files
|
||||||
**npmts** also creates an `index.d.ts` declaration file by default.
|
**npmts** also creates an `./dist/index.d.ts` declaration file by default.
|
||||||
You can reference it in your package.json like this:
|
You can reference it in your package.json like this.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "./index.d.ts",
|
"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
|
#### Instrumentalize Code
|
||||||
npmts instrumentalizes the created JavaScript code to create a coverage report.
|
npmts instrumentalizes (using istanbul) the created JavaScript code to create a coverage report.
|
||||||
|
|
||||||
#### Tests
|
#### Tests
|
||||||
When Typings have been installed, TypeScript + Declaration files have been transpiled and the resulting JS has been instrumentalized,
|
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.
|
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.
|
Any errors will be shown with reference to their originating source in TypeScript
|
||||||
|
thanks to autogenerated source maps.
|
||||||
|
|
||||||
When requiring the module from other TypeScript files,
|
## Example Usage in modules:
|
||||||
the TypeScript Compiler will use the declaration file to resolve typings.
|
[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/)
|
||||||
|
|
||||||
### Custom behaviour
|
[](https://paypal.me/lossless)
|
||||||
Custom behaviour can be achieved through a config file at the root of your package.
|
|
||||||
The file must be named **npmts.json**
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"mode":"custom",
|
|
||||||
"ts":{
|
|
||||||
"./customdir/custom.ts":"./customcompiled.js"
|
|
||||||
},
|
|
||||||
"typings":[
|
|
||||||
"./customdir"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
* **mode** can be "default" or "custom"
|
|
||||||
* **ts** You can list as many TypeScript files as you like. The key represents the source TypeScript file, the value the output file.
|
|
||||||
* **typings** is an array of all direcories that have a typings.json present. Uses the new typings tool from npm.
|
|
||||||
|
|
||||||
|
|
||||||
## Readme for Devs
|
|
||||||
There is a [README-dev.md](README-dev.md) in the repo.
|
|
||||||
This is only of interest for you when looking to contribute to, improve or build upon this package.
|
|
7
dist/index.js
vendored
7
dist/index.js
vendored
@ -4,4 +4,9 @@ console.log("**** starting NPMTS ****");
|
|||||||
var plugins = require("./npmts.plugins");
|
var plugins = require("./npmts.plugins");
|
||||||
var promisechain = require("./npmts.promisechain");
|
var promisechain = require("./npmts.promisechain");
|
||||||
plugins.beautylog.figletSync("NPMTS");
|
plugins.beautylog.figletSync("NPMTS");
|
||||||
promisechain.run();
|
try {
|
||||||
|
promisechain.run();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
4
dist/npmts.assets.js
vendored
4
dist/npmts.assets.js
vendored
@ -5,8 +5,10 @@ var paths = require("./npmts.paths");
|
|||||||
exports.run = function (configArg) {
|
exports.run = function (configArg) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
var config = configArg;
|
var config = configArg;
|
||||||
|
plugins.beautylog.log("now looking at required assets");
|
||||||
if (config.cli == true) {
|
if (config.cli == true) {
|
||||||
plugins.smartfile.copy(plugins.path.join(paths.npmtsAssetsDir, "cli.js"), paths.distDir);
|
plugins.smartfile.fsaction.copy(plugins.path.join(paths.npmtsAssetsDir, "cli.js"), paths.distDir);
|
||||||
|
plugins.beautylog.ok("CLI asset has been installed!");
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
14
dist/npmts.clean.js
vendored
Normal file
14
dist/npmts.clean.js
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
plugins.beautylog.log("now cleaning up from previous builds...");
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
plugins.smartfile.fsaction.remove(paths.distDir)
|
||||||
|
.then(function () {
|
||||||
|
plugins.beautylog.ok("Cleaned up!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
16
dist/npmts.compile.helpers.js
vendored
Normal file
16
dist/npmts.compile.helpers.js
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"use strict";
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var outputPathIsDir = function (configArg, keyArg) {
|
||||||
|
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, configArg.ts[keyArg]));
|
||||||
|
};
|
||||||
|
exports.checkOutputPath = function (configArg, keyArg) {
|
||||||
|
if (!outputPathIsDir(configArg, keyArg)) {
|
||||||
|
plugins.beautylog.warn("Skipping " + keyArg + " because " + configArg.ts[keyArg] + " it is no directory!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
};
|
72
dist/npmts.compile.js
vendored
72
dist/npmts.compile.js
vendored
@ -2,6 +2,7 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
var plugins = require("./npmts.plugins");
|
var plugins = require("./npmts.plugins");
|
||||||
var paths = require("./npmts.paths");
|
var paths = require("./npmts.paths");
|
||||||
|
var helpers = require("./npmts.compile.helpers");
|
||||||
exports.run = function (configArg) {
|
exports.run = function (configArg) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
var config = configArg;
|
var config = configArg;
|
||||||
@ -10,53 +11,44 @@ exports.run = function (configArg) {
|
|||||||
/* -------------------------------------------------
|
/* -------------------------------------------------
|
||||||
* ----------- compile TypeScript --------------------------
|
* ----------- compile TypeScript --------------------------
|
||||||
* ----------------------------------------------- */
|
* ----------------------------------------------- */
|
||||||
for (var key in config.ts) {
|
var tsOptionsDefault = {
|
||||||
var outputPathIsDir;
|
declaration: true,
|
||||||
try {
|
target: "ES5",
|
||||||
if (plugins.fs.statSync(plugins.path.join(paths.cwd, config.ts[key])).isDirectory()) {
|
module: "commonjs"
|
||||||
outputPathIsDir = true;
|
};
|
||||||
}
|
/**
|
||||||
|
* merges default ts options with those found in npmts.json
|
||||||
|
*/
|
||||||
|
var tsOptions = function (keyArg) {
|
||||||
|
return plugins.lodashObject.assign(tsOptionsDefault, config.tsOptions);
|
||||||
|
};
|
||||||
|
for (var keyArg in config.ts) {
|
||||||
|
if (helpers.checkOutputPath(config, keyArg)) {
|
||||||
|
var tsStream = plugins.gulp.src([plugins.path.join(paths.cwd, keyArg), "!**/typings/**"])
|
||||||
|
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
||||||
|
.pipe(plugins.g.typescript(tsOptions(keyArg)));
|
||||||
|
var jsStream = tsStream.js
|
||||||
|
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||||
|
.pipe(plugins.gulp.dest(config.ts[keyArg]));
|
||||||
|
var declarationStream = tsStream.dts
|
||||||
|
.pipe(plugins.gulp.dest(config.ts[keyArg]));
|
||||||
|
moduleStream.add(tsStream, jsStream, declarationStream);
|
||||||
}
|
}
|
||||||
catch (err) {
|
|
||||||
outputPathIsDir = false;
|
|
||||||
}
|
|
||||||
//do some evaluation of the environment
|
|
||||||
var outputNameSpecified = (!outputPathIsDir
|
|
||||||
&& (plugins.path.extname(config.ts[key]) == ".js"));
|
|
||||||
var outputName = (function () {
|
|
||||||
if (outputNameSpecified) {
|
|
||||||
return plugins.path.basename(config.ts[key]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
var outputDir = (function () {
|
|
||||||
if (outputNameSpecified) {
|
|
||||||
return plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return plugins.path.join(paths.cwd, config.ts[key]);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, key), "!**/typings/**"])
|
|
||||||
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
|
||||||
.pipe(plugins.g.typescript({
|
|
||||||
out: outputName,
|
|
||||||
target: "ES5",
|
|
||||||
module: "commonjs"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
|
||||||
.pipe(plugins.gulp.dest(outputDir));
|
|
||||||
moduleStream.add(stream);
|
|
||||||
}
|
}
|
||||||
moduleStream.on("queueDrain", function () {
|
moduleStream.on("queueDrain", function () {
|
||||||
plugins.beautylog.ok("TypeScript is compiled!");
|
plugins.beautylog.ok("TypeScript has been compiled!");
|
||||||
moduleStream.on("finish", function () {
|
moduleStream.on("finish", function () {
|
||||||
|
try {
|
||||||
|
if (config.mode = "default")
|
||||||
|
plugins.fs.copySync(plugins.path.join(paths.cwd, "ts/typings"), plugins.path.join(paths.cwd, "dist/typings"));
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
plugins.beautylog.warn("failed to copy external typings for full module declaration support");
|
||||||
|
}
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
});
|
});
|
||||||
moduleStream.end();
|
moduleStream.end();
|
||||||
});
|
});
|
||||||
/*==================== END TYPESCRIPT =====================*/
|
/*==================== END TS Compilation =====================*/
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
4
dist/npmts.configfile.js
vendored
4
dist/npmts.configfile.js
vendored
@ -8,11 +8,11 @@ exports.run = function () {
|
|||||||
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:
|
||||||
|
4
dist/npmts.install.js
vendored
4
dist/npmts.install.js
vendored
@ -9,11 +9,11 @@ exports.run = function (configArg) {
|
|||||||
* ----------- install typings ---------------
|
* ----------- install typings ---------------
|
||||||
* ----------------------------------------------- */
|
* ----------------------------------------------- */
|
||||||
plugins.beautylog.log("now installing " + "typings".yellow);
|
plugins.beautylog.log("now installing " + "typings".yellow);
|
||||||
var absoluteTypingsArray = plugins.smartpath.absolute(config.typings, paths.cwd);
|
var absoluteTypingsArray = plugins.smartpath.transform.toAbsolute(config.typings, paths.cwd);
|
||||||
plugins.gulp.src(absoluteTypingsArray)
|
plugins.gulp.src(absoluteTypingsArray)
|
||||||
.pipe(plugins.g.typings())
|
.pipe(plugins.g.typings())
|
||||||
.pipe(plugins.g.gFunction(function () {
|
.pipe(plugins.g.gFunction(function () {
|
||||||
plugins.beautylog.ok("typings are installed!");
|
plugins.beautylog.ok("typings have been installed!");
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
}, "atEnd"));
|
}, "atEnd"));
|
||||||
return done.promise;
|
return done.promise;
|
||||||
|
28
dist/npmts.jsdoc.js
vendored
28
dist/npmts.jsdoc.js
vendored
@ -14,12 +14,12 @@ var genJsdoc = function (configArg) {
|
|||||||
destination: paths.docsDir
|
destination: paths.docsDir
|
||||||
}
|
}
|
||||||
}, function () {
|
}, function () {
|
||||||
plugins.beautylog.ok("JsDoc has been generated!");
|
plugins.beautylog.ok("JsDoc documentation has been generated!");
|
||||||
done.resolve(configArg);
|
done.resolve(configArg);
|
||||||
}));
|
}));
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
var publishDocs = function (configArg) {
|
exports.publishDocs = function (configArg) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
var gitUrl = plugins.projectinfo.npm(paths.cwd, {
|
var gitUrl = plugins.projectinfo.npm(paths.cwd, {
|
||||||
gitAccessToken: process.env.GITHUB_TOKEN
|
gitAccessToken: process.env.GITHUB_TOKEN
|
||||||
@ -34,28 +34,22 @@ var publishDocs = function (configArg) {
|
|||||||
+ "&& git push --force --quiet "
|
+ "&& git push --force --quiet "
|
||||||
+ "\"" + gitUrl + "\" "
|
+ "\"" + gitUrl + "\" "
|
||||||
+ "master:gh-pages " + "> /dev/null 2>&1";
|
+ "master:gh-pages " + "> /dev/null 2>&1";
|
||||||
if (plugins.smartenv.getEnv().isTravis && configArg.docs && configArg.docs.publish) {
|
plugins.beautylog.log("now publishing JsDoc documentation to GitHub");
|
||||||
plugins.beautylog.log("now publishing docs to GitHub");
|
if (!plugins.shelljs.which('git')) {
|
||||||
if (!plugins.shelljs.which('git')) {
|
plugins.beautylog.error('Git is not installed!');
|
||||||
plugins.beautylog.error('Git is not installed!');
|
plugins.shelljs.exit(1);
|
||||||
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 has been deployed to GitHub!");
|
|
||||||
done.resolve(configArg);
|
|
||||||
}
|
}
|
||||||
else {
|
else if (plugins.shelljs.exec(deployScript).code !== 0) {
|
||||||
done.resolve(configArg);
|
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;
|
return done.promise;
|
||||||
};
|
};
|
||||||
exports.run = function (configArg) {
|
exports.run = function (configArg) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
genJsdoc(configArg)
|
genJsdoc(configArg)
|
||||||
.then(publishDocs)
|
|
||||||
.then(done.resolve);
|
.then(done.resolve);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
37
dist/npmts.options.js
vendored
37
dist/npmts.options.js
vendored
@ -1,12 +1,22 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
var plugins = require("./npmts.plugins");
|
var plugins = require("./npmts.plugins");
|
||||||
|
exports.isCi = function () {
|
||||||
|
return plugins.smartci.check.isCi();
|
||||||
|
};
|
||||||
|
exports.isRelease = function () {
|
||||||
|
return plugins.smartci.check.isCi()
|
||||||
|
&& plugins.smartci.check.isTaggedCommit();
|
||||||
|
};
|
||||||
|
exports.doPublish = function () {
|
||||||
|
return exports.isRelease()
|
||||||
|
&& plugins.smartci.get.subJobNumber() == 1;
|
||||||
|
};
|
||||||
exports.run = function (configArg) {
|
exports.run = function (configArg) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
var config = configArg;
|
var config = configArg;
|
||||||
if (typeof config.coveralls === "undefined") {
|
plugins.beautylog.log("now determining build options...");
|
||||||
config.coveralls = false;
|
//handle default mode
|
||||||
}
|
|
||||||
if (config.mode == "default") {
|
if (config.mode == "default") {
|
||||||
config.typings = [
|
config.typings = [
|
||||||
"./ts/typings.json"
|
"./ts/typings.json"
|
||||||
@ -17,11 +27,24 @@ exports.run = function (configArg) {
|
|||||||
_a
|
_a
|
||||||
);
|
);
|
||||||
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 = {};
|
||||||
|
// 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;
|
return done.promise;
|
||||||
var _a;
|
var _a;
|
||||||
};
|
};
|
||||||
|
1
dist/npmts.paths.js
vendored
1
dist/npmts.paths.js
vendored
@ -8,6 +8,7 @@ paths.tsDir = plugins.path.join(paths.cwd, "ts/");
|
|||||||
paths.distDir = plugins.path.join(paths.cwd, "dist/");
|
paths.distDir = plugins.path.join(paths.cwd, "dist/");
|
||||||
paths.docsDir = plugins.path.join(paths.cwd, "docs/");
|
paths.docsDir = plugins.path.join(paths.cwd, "docs/");
|
||||||
paths.testDir = plugins.path.join(paths.cwd, "test/");
|
paths.testDir = plugins.path.join(paths.cwd, "test/");
|
||||||
|
paths.coverageDir = plugins.path.join(paths.cwd, "coverage/");
|
||||||
paths.npmtsAssetsDir = plugins.path.join(__dirname, "../assets/");
|
paths.npmtsAssetsDir = plugins.path.join(__dirname, "../assets/");
|
||||||
//Files
|
//Files
|
||||||
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
||||||
|
50
dist/npmts.plugins.js
vendored
50
dist/npmts.plugins.js
vendored
@ -1,28 +1,28 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
var plugins = {
|
exports.beautylog = require("beautylog");
|
||||||
beautylog: require("beautylog"),
|
exports.fs = require("fs-extra");
|
||||||
fs: require("fs-extra"),
|
exports.gulp = require("gulp");
|
||||||
gulp: require("gulp"),
|
exports.g = {
|
||||||
g: {
|
codecov: require("gulp-codecov"),
|
||||||
coveralls: require("gulp-coveralls"),
|
gFunction: require("gulp-function"),
|
||||||
gFunction: require("gulp-function"),
|
istanbul: require("gulp-istanbul"),
|
||||||
istanbul: require("gulp-istanbul"),
|
jsdoc3: require("gulp-jsdoc3"),
|
||||||
jsdoc3: require("gulp-jsdoc3"),
|
mocha: require("gulp-mocha"),
|
||||||
mocha: require("gulp-mocha"),
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
sourcemaps: require("gulp-sourcemaps"),
|
typescript: require("gulp-typescript"),
|
||||||
typescript: require("gulp-typescript"),
|
typings: require("gulp-typings")
|
||||||
typings: require("gulp-typings")
|
|
||||||
},
|
|
||||||
merge2: require("merge2"),
|
|
||||||
projectinfo: require("projectinfo"),
|
|
||||||
sourceMapSupport: require("source-map-support").install(),
|
|
||||||
path: require("path"),
|
|
||||||
Q: require("q"),
|
|
||||||
shelljs: require("shelljs"),
|
|
||||||
smartcli: require("smartcli"),
|
|
||||||
smartenv: require("smartenv"),
|
|
||||||
smartfile: require("smartfile"),
|
|
||||||
smartpath: require("smartpath")
|
|
||||||
};
|
};
|
||||||
module.exports = plugins;
|
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.sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing
|
||||||
|
7
dist/npmts.promisechain.js
vendored
7
dist/npmts.promisechain.js
vendored
@ -2,21 +2,25 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
var plugins = require("./npmts.plugins");
|
var plugins = require("./npmts.plugins");
|
||||||
var NpmtsAssets = require("./npmts.assets");
|
var NpmtsAssets = require("./npmts.assets");
|
||||||
|
var NpmtsClean = require("./npmts.clean");
|
||||||
var NpmtsCompile = require("./npmts.compile");
|
var NpmtsCompile = require("./npmts.compile");
|
||||||
var NpmtsConfigFile = require("./npmts.configfile");
|
var NpmtsConfigFile = require("./npmts.configfile");
|
||||||
var NpmtsInstall = require("./npmts.install");
|
var NpmtsInstall = require("./npmts.install");
|
||||||
var NpmtsJsdoc = require("./npmts.jsdoc");
|
var NpmtsJsdoc = require("./npmts.jsdoc");
|
||||||
var NpmtsOptions = require("./npmts.options");
|
var NpmtsOptions = require("./npmts.options");
|
||||||
|
var NpmtsPublish = require("./npmts.publish");
|
||||||
var NpmtsTests = require("./npmts.tests");
|
var NpmtsTests = require("./npmts.tests");
|
||||||
exports.run = function () {
|
exports.run = function () {
|
||||||
var promisechain;
|
var promisechain;
|
||||||
NpmtsConfigFile.run()
|
NpmtsConfigFile.run()
|
||||||
.then(NpmtsOptions.run)
|
.then(NpmtsOptions.run)
|
||||||
|
.then(NpmtsClean.run)
|
||||||
.then(NpmtsInstall.run)
|
.then(NpmtsInstall.run)
|
||||||
.then(NpmtsCompile.run)
|
.then(NpmtsCompile.run)
|
||||||
.then(NpmtsAssets.run)
|
.then(NpmtsAssets.run)
|
||||||
.then(NpmtsJsdoc.run)
|
.then(NpmtsJsdoc.run)
|
||||||
.then(NpmtsTests.run)
|
.then(NpmtsTests.run)
|
||||||
|
.then(NpmtsPublish.run)
|
||||||
.then(function (configArg) {
|
.then(function (configArg) {
|
||||||
var shipString = "" +
|
var shipString = "" +
|
||||||
"\n" +
|
"\n" +
|
||||||
@ -36,6 +40,9 @@ exports.run = function () {
|
|||||||
console.log(shipString);
|
console.log(shipString);
|
||||||
plugins.beautylog.success("READY TO SHIP!");
|
plugins.beautylog.success("READY TO SHIP!");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
plugins.beautylog.success("Done!");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return promisechain;
|
return promisechain;
|
||||||
};
|
};
|
||||||
|
15
dist/npmts.publish.js
vendored
Normal file
15
dist/npmts.publish.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var NpmtsTests = require("./npmts.tests");
|
||||||
|
var NpmtsJsdoc = require("./npmts.jsdoc");
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
var promiseArray = [];
|
||||||
|
config.codecov ? promiseArray.push(NpmtsTests.publishCoverage(configArg)) : void (0);
|
||||||
|
config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void (0);
|
||||||
|
promiseArray.length === 0 ? plugins.beautylog.info("Did not publish anything!") : void (0);
|
||||||
|
plugins.Q.all(promiseArray).then(done.resolve);
|
||||||
|
return done.promise;
|
||||||
|
};
|
106
dist/npmts.tests.js
vendored
106
dist/npmts.tests.js
vendored
@ -2,44 +2,76 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
var plugins = require("./npmts.plugins");
|
var plugins = require("./npmts.plugins");
|
||||||
var paths = require("./npmts.paths");
|
var paths = require("./npmts.paths");
|
||||||
exports.run = function (configArg) {
|
exports.publishCoverage = function (configArg) {
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
var config = configArg;
|
plugins.beautylog.log("now uploading coverage data to codecov.io");
|
||||||
var istanbul = function () {
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
|
.pipe(plugins.g.codecov())
|
||||||
.pipe(plugins.g.istanbul())
|
.pipe(plugins.g.gFunction(function () {
|
||||||
.pipe(plugins.g.istanbul.hookRequire());
|
plugins.beautylog.ok("Coverage data has been uploaded to codecov.io!");
|
||||||
return stream;
|
done.resolve(configArg);
|
||||||
};
|
}, "atEnd"));
|
||||||
var mocha = function () {
|
return done.promise;
|
||||||
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 } }));
|
* @returns {*}
|
||||||
return stream;
|
*/
|
||||||
};
|
var istanbul = function (configArg) {
|
||||||
var coveralls = function () {
|
var done = plugins.Q.defer();
|
||||||
plugins.beautylog.log("now uploading coverage data to coveralls");
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "./coverage/lcov.info")])
|
.pipe(plugins.g.istanbul()) // Covering files
|
||||||
.pipe(plugins.g.coveralls())
|
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
|
||||||
.pipe(plugins.g.gFunction(function () {
|
.pipe(plugins.g.gFunction(function () {
|
||||||
plugins.beautylog.ok("Tests have passed and coverage data has been uploaded to Coveralls!");
|
done.resolve(configArg);
|
||||||
}, "atEnd"));
|
}, "atEnd"));
|
||||||
return stream;
|
return done.promise;
|
||||||
};
|
};
|
||||||
plugins.beautylog.log("now starting tests");
|
/**
|
||||||
istanbul().on("finish", function () {
|
*
|
||||||
mocha().on("finish", function () {
|
* @returns {*}
|
||||||
if (plugins.smartenv.getEnv().isTravis && config.coveralls) {
|
*/
|
||||||
coveralls().on("finish", function () {
|
var mocha = function (configArg) {
|
||||||
done.resolve(config);
|
var done = plugins.Q.defer();
|
||||||
});
|
var stream = plugins.gulp.src(["./test/test.js"])
|
||||||
}
|
.pipe(plugins.g.mocha())
|
||||||
else {
|
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
|
||||||
plugins.beautylog.ok("Tests have passed!");
|
.pipe(plugins.g.gFunction(function () {
|
||||||
done.resolve(config);
|
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;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
plugins.beautylog.log("now starting tests");
|
||||||
|
console.log("--------------------------------------------------------------\n" +
|
||||||
|
"***************************" +
|
||||||
|
" TESTS: ".blue +
|
||||||
|
"***************************\n" +
|
||||||
|
"--------------------------------------------------------------");
|
||||||
|
istanbul(config)
|
||||||
|
.then(mocha)
|
||||||
|
.then(coverage)
|
||||||
|
.then(done.resolve);
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
31
package.json
31
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "3.5.0",
|
"version": "5.1.3",
|
||||||
"description": "write npm modules with TypeScript",
|
"description": "write npm modules with TypeScript",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -25,27 +25,30 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/npmts#readme",
|
"homepage": "https://github.com/pushrocks/npmts#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "3.1.2",
|
"beautylog": "4.1.2",
|
||||||
"fs-extra": "^0.26.5",
|
"fs-extra": "^0.30.0",
|
||||||
"gulp": "3.9.1",
|
"gulp": "3.9.1",
|
||||||
|
"gulp-codecov": "^2.0.1",
|
||||||
"gulp-concat": "^2.6.0",
|
"gulp-concat": "^2.6.0",
|
||||||
"gulp-coveralls": "^0.1.4",
|
"gulp-function": "^1.3.1",
|
||||||
"gulp-function": "^1.1.1",
|
|
||||||
"gulp-if": "^2.0.0",
|
"gulp-if": "^2.0.0",
|
||||||
"gulp-istanbul": "^0.10.3",
|
"gulp-istanbul": "^0.10.4",
|
||||||
"gulp-jsdoc3": "^0.2.1",
|
"gulp-jsdoc3": "^0.2.1",
|
||||||
"gulp-mocha": "^2.2.0",
|
"gulp-mocha": "^2.2.0",
|
||||||
"gulp-sourcemaps": "^1.6.0",
|
"gulp-sourcemaps": "^2.0.0-alpha",
|
||||||
"gulp-typescript": "2.12.1",
|
"gulp-typescript": "2.13.0",
|
||||||
"gulp-typings": "1.2.0",
|
"gulp-typings": "1.3.4",
|
||||||
"merge2": "1.0.1",
|
"lodash": "^4.11.1",
|
||||||
|
"merge2": "1.0.2",
|
||||||
"projectinfo": "1.0.1",
|
"projectinfo": "1.0.1",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"shelljs": "^0.6.0",
|
"shelljs": "^0.7.0",
|
||||||
|
"smartci": "0.0.1",
|
||||||
"smartcli": "0.0.11",
|
"smartcli": "0.0.11",
|
||||||
"smartenv": "1.2.0",
|
"smartcov": "0.0.6",
|
||||||
"smartfile": "1.0.1",
|
"smartenv": "1.2.2",
|
||||||
"smartpath": "2.1.0",
|
"smartfile": "3.0.5",
|
||||||
|
"smartpath": "3.1.5",
|
||||||
"source-map-support": "^0.4.0"
|
"source-map-support": "^0.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {}
|
"devDependencies": {}
|
||||||
|
2
test/assets/dist/cli.js
vendored
2
test/assets/dist/cli.js
vendored
@ -1,2 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
var index = require("./index.js");
|
|
4
test/assets/dist/index.d.ts
vendored
Normal file
4
test/assets/dist/index.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/// <reference path="typings/main.d.ts" />
|
||||||
|
declare let testplugin: {
|
||||||
|
logSomething: () => void;
|
||||||
|
};
|
2
test/assets/dist/index.js
vendored
2
test/assets/dist/index.js
vendored
@ -6,4 +6,4 @@ var testplugin = {
|
|||||||
};
|
};
|
||||||
module.exports = testplugin;
|
module.exports = testplugin;
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxudmFyIHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxubGV0IHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXX0=
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
{
|
{
|
||||||
"mode":"custom",
|
"mode":"default",
|
||||||
"ts":{
|
"ts":{
|
||||||
"./customdir/*.ts":"./"
|
"./customdir/*.ts":"./"
|
||||||
},
|
},
|
||||||
|
"tsOptions":{
|
||||||
|
"target":"ES5"
|
||||||
|
},
|
||||||
"typings":[
|
"typings":[
|
||||||
"./ts/typings.json",
|
"./ts/typings.json",
|
||||||
"./subts1/typings.json",
|
"./subts1/typings.json",
|
||||||
"./subts2/typings.json",
|
"./subts2/typings.json",
|
||||||
"./customdir/typings.json"
|
"./customdir/typings.json"
|
||||||
],
|
],
|
||||||
"coveralls":true,
|
"codecov":true,
|
||||||
"docs": {
|
"docs": {
|
||||||
"publish":true
|
"publish":true
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
console.log("**** starting test ****");
|
|
||||||
var testplugin = require("../dist/index.js");
|
var testplugin = require("../dist/index.js");
|
||||||
describe("testplugins", function () {
|
describe("testplugins", function () {
|
||||||
describe(".logSomething", function () {
|
describe(".logSomething", function () {
|
||||||
@ -9,4 +8,4 @@ describe("testplugins", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELE9BQU8sQ0FBQyxHQUFHLENBQUMseUJBQXlCLENBQUMsQ0FBQztBQUN2QyxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQztBQUM3QyxRQUFRLENBQUMsYUFBYSxFQUFDO0lBQ25CLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsRUFBRSxDQUFDLHNCQUFzQixFQUFDO1lBQ3RCLFVBQVUsQ0FBQyxZQUFZLEVBQUUsQ0FBQTtRQUM3QixDQUFDLENBQUMsQ0FBQztJQUNQLENBQUMsQ0FBQyxDQUFDO0FBQ1AsQ0FBQyxDQUFDLENBQUMiLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuLi90cy90eXBpbmdzL21haW4uZC50c1wiIC8+XG5jb25zb2xlLmxvZyhcIioqKiogc3RhcnRpbmcgdGVzdCAqKioqXCIpO1xudmFyIHRlc3RwbHVnaW4gPSByZXF1aXJlKFwiLi4vZGlzdC9pbmRleC5qc1wiKTtcbmRlc2NyaWJlKFwidGVzdHBsdWdpbnNcIixmdW5jdGlvbigpe1xuICAgIGRlc2NyaWJlKFwiLmxvZ1NvbWV0aGluZ1wiLGZ1bmN0aW9uKCl7XG4gICAgICAgIGl0KFwic2hvdWxkIGxvZyBzb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgdGVzdHBsdWdpbi5sb2dTb21ldGhpbmcoKVxuICAgICAgICB9KTtcbiAgICB9KTtcbn0pOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksVUFBVSxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzdDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixFQUFFLENBQUMsc0JBQXNCLEVBQUM7WUFDdEIsVUFBVSxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQzdCLENBQUMsQ0FBQyxDQUFDO0lBQ1AsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbnZhciB0ZXN0cGx1Z2luID0gcmVxdWlyZShcIi4uL2Rpc3QvaW5kZXguanNcIik7XG5kZXNjcmliZShcInRlc3RwbHVnaW5zXCIsZnVuY3Rpb24oKXtcbiAgICBkZXNjcmliZShcIi5sb2dTb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICBpdChcInNob3VsZCBsb2cgc29tZXRoaW5nXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIHRlc3RwbHVnaW4ubG9nU29tZXRoaW5nKClcbiAgICAgICAgfSk7XG4gICAgfSk7XG59KTsiXX0=
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AACvC,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"}
|
{"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"}
|
@ -1,5 +1,4 @@
|
|||||||
/// <reference path="../ts/typings/main.d.ts" />
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
console.log("**** starting test ****");
|
|
||||||
var testplugin = require("../dist/index.js");
|
var testplugin = require("../dist/index.js");
|
||||||
describe("testplugins",function(){
|
describe("testplugins",function(){
|
||||||
describe(".logSomething",function(){
|
describe(".logSomething",function(){
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
var testplugin = {
|
let testplugin = {
|
||||||
logSomething: function(){
|
logSomething: function(){
|
||||||
console.log("only function executed");
|
console.log("only function executed");
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"ambientDependencies": {
|
"ambientDependencies": {
|
||||||
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,11 @@ console.log("**** starting NPMTS ****");
|
|||||||
import plugins = require("./npmts.plugins");
|
import plugins = require("./npmts.plugins");
|
||||||
import promisechain = require("./npmts.promisechain");
|
import promisechain = require("./npmts.promisechain");
|
||||||
plugins.beautylog.figletSync("NPMTS");
|
plugins.beautylog.figletSync("NPMTS");
|
||||||
promisechain.run();
|
|
||||||
|
try {
|
||||||
|
promisechain.run();
|
||||||
|
}
|
||||||
|
catch(err){
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,10 @@ import paths = require("./npmts.paths");
|
|||||||
export var run = function(configArg){
|
export var run = function(configArg){
|
||||||
let done = plugins.Q.defer();
|
let done = plugins.Q.defer();
|
||||||
let config = configArg;
|
let config = configArg;
|
||||||
|
plugins.beautylog.log("now looking at required assets");
|
||||||
if(config.cli == true){
|
if(config.cli == true){
|
||||||
plugins.smartfile.copy(plugins.path.join(paths.npmtsAssetsDir,"cli.js"),paths.distDir);
|
plugins.smartfile.fsaction.copy(plugins.path.join(paths.npmtsAssetsDir,"cli.js"),paths.distDir);
|
||||||
|
plugins.beautylog.ok("CLI asset has been installed!");
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
} else {
|
} else {
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
|
14
ts/npmts.clean.ts
Normal file
14
ts/npmts.clean.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
|
||||||
|
export let run = function(configArg){
|
||||||
|
plugins.beautylog.log("now cleaning up from previous builds...");
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
plugins.smartfile.fsaction.remove(paths.distDir)
|
||||||
|
.then(function(){
|
||||||
|
plugins.beautylog.ok("Cleaned up!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
15
ts/npmts.compile.helpers.ts
Normal file
15
ts/npmts.compile.helpers.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
|
||||||
|
let outputPathIsDir = function (configArg,keyArg) {
|
||||||
|
return plugins.smartpath.check.isDir(plugins.path.join(paths.cwd, configArg.ts[keyArg]));
|
||||||
|
};
|
||||||
|
|
||||||
|
export let checkOutputPath = function(configArg,keyArg){
|
||||||
|
if(!outputPathIsDir(configArg,keyArg)) {
|
||||||
|
plugins.beautylog.warn("Skipping " + keyArg + " because " + configArg.ts[keyArg] + " it is no directory!")
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
@ -1,67 +1,64 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
import plugins = require("./npmts.plugins");
|
import plugins = require("./npmts.plugins");
|
||||||
import paths = require("./npmts.paths");
|
import paths = require("./npmts.paths");
|
||||||
export var run = function(configArg){
|
|
||||||
var done = plugins.Q.defer();
|
import helpers = require("./npmts.compile.helpers");
|
||||||
var config = configArg;
|
|
||||||
|
export let run = function (configArg) {
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let config = configArg;
|
||||||
plugins.beautylog.log("now compiling " + "TypeScript".yellow);
|
plugins.beautylog.log("now compiling " + "TypeScript".yellow);
|
||||||
var moduleStream = plugins.merge2({end: false});
|
let moduleStream = plugins.merge2({ end: false });
|
||||||
|
|
||||||
/* -------------------------------------------------
|
/* -------------------------------------------------
|
||||||
* ----------- compile TypeScript --------------------------
|
* ----------- compile TypeScript --------------------------
|
||||||
* ----------------------------------------------- */
|
* ----------------------------------------------- */
|
||||||
for (var key in config.ts) {
|
|
||||||
var outputPathIsDir:boolean;
|
|
||||||
try {
|
|
||||||
if(plugins.fs.statSync(plugins.path.join(paths.cwd,config.ts[key])).isDirectory()){
|
|
||||||
outputPathIsDir = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(err) {
|
|
||||||
outputPathIsDir = false;
|
|
||||||
}
|
|
||||||
//do some evaluation of the environment
|
|
||||||
var outputNameSpecified:boolean = (
|
|
||||||
!outputPathIsDir
|
|
||||||
&& (plugins.path.extname(config.ts[key]) == ".js")
|
|
||||||
);
|
|
||||||
var outputName = (function(){
|
|
||||||
if(outputNameSpecified){
|
|
||||||
return plugins.path.basename(config.ts[key])
|
|
||||||
} else {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
var outputDir = (function(){
|
|
||||||
if(outputNameSpecified){
|
|
||||||
return plugins.path.dirname(
|
|
||||||
plugins.path.join(paths.cwd,config.ts[key])
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return plugins.path.join(paths.cwd,config.ts[key])
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,key),"!**/typings/**"])
|
let tsOptionsDefault = {
|
||||||
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
declaration: true,
|
||||||
.pipe(plugins.g.typescript({
|
target: "ES5",
|
||||||
out: outputName,
|
module: "commonjs"
|
||||||
target: "ES5",
|
};
|
||||||
module: "commonjs"
|
|
||||||
}))
|
/**
|
||||||
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
* merges default ts options with those found in npmts.json
|
||||||
//.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
|
*/
|
||||||
.pipe(plugins.gulp.dest(outputDir));
|
let tsOptions = function (keyArg:string) {
|
||||||
moduleStream.add(stream);
|
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(){
|
|
||||||
plugins.beautylog.ok("TypeScript is compiled!");
|
moduleStream.on("queueDrain", function () {
|
||||||
moduleStream.on("finish",function(){
|
plugins.beautylog.ok("TypeScript has been compiled!");
|
||||||
|
moduleStream.on("finish", function () {
|
||||||
|
try {
|
||||||
|
if(config.mode = "default") plugins.fs.copySync(
|
||||||
|
plugins.path.join(paths.cwd,"ts/typings"),
|
||||||
|
plugins.path.join(paths.cwd,"dist/typings")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (err){
|
||||||
|
plugins.beautylog.warn("failed to copy external typings for full module declaration support");
|
||||||
|
}
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
});
|
});
|
||||||
moduleStream.end();
|
moduleStream.end();
|
||||||
});
|
});
|
||||||
/*==================== END TYPESCRIPT =====================*/
|
/*==================== END TS Compilation =====================*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ export var run = function(){
|
|||||||
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:
|
||||||
|
@ -8,11 +8,11 @@ export var run = function(configArg){
|
|||||||
* ----------- install typings ---------------
|
* ----------- install typings ---------------
|
||||||
* ----------------------------------------------- */
|
* ----------------------------------------------- */
|
||||||
plugins.beautylog.log("now installing " + "typings".yellow);
|
plugins.beautylog.log("now installing " + "typings".yellow);
|
||||||
let absoluteTypingsArray = plugins.smartpath.absolute(config.typings,paths.cwd);
|
var absoluteTypingsArray = plugins.smartpath.transform.toAbsolute(config.typings,paths.cwd);
|
||||||
plugins.gulp.src(absoluteTypingsArray)
|
plugins.gulp.src(absoluteTypingsArray)
|
||||||
.pipe(plugins.g.typings())
|
.pipe(plugins.g.typings())
|
||||||
.pipe(plugins.g.gFunction(function(){
|
.pipe(plugins.g.gFunction(function(){
|
||||||
plugins.beautylog.ok("typings are installed!");
|
plugins.beautylog.ok("typings have been installed!");
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
},"atEnd"));
|
},"atEnd"));
|
||||||
return done.promise;
|
return done.promise;
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
import plugins = require("./npmts.plugins");
|
import plugins = require("./npmts.plugins");
|
||||||
import paths = require("./npmts.paths");
|
import paths = require("./npmts.paths");
|
||||||
|
|
||||||
var genJsdoc = function(configArg){
|
let genJsdoc = function(configArg){
|
||||||
var done = plugins.Q.defer();
|
let done = plugins.Q.defer();
|
||||||
plugins.beautylog.log("now generating " + "JsDoc documentation".blue);
|
plugins.beautylog.log("now generating " + "JsDoc documentation".blue);
|
||||||
plugins.gulp.src([
|
plugins.gulp.src([
|
||||||
plugins.path.join(paths.cwd,"README.md"),
|
plugins.path.join(paths.cwd,"README.md"),
|
||||||
@ -14,22 +14,22 @@ var genJsdoc = function(configArg){
|
|||||||
destination: paths.docsDir
|
destination: paths.docsDir
|
||||||
}
|
}
|
||||||
}, function(){
|
}, function(){
|
||||||
plugins.beautylog.ok("JsDoc has been generated!");
|
plugins.beautylog.ok("JsDoc documentation has been generated!");
|
||||||
done.resolve(configArg)
|
done.resolve(configArg)
|
||||||
}));
|
}));
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
var publishDocs = function(configArg){
|
export let publishDocs = function(configArg){
|
||||||
var done = plugins.Q.defer();
|
let done = plugins.Q.defer();
|
||||||
var gitUrl = plugins.projectinfo.npm(
|
let gitUrl = plugins.projectinfo.npm(
|
||||||
paths.cwd,
|
paths.cwd,
|
||||||
{
|
{
|
||||||
gitAccessToken:process.env.GITHUB_TOKEN
|
gitAccessToken:process.env.GITHUB_TOKEN
|
||||||
}
|
}
|
||||||
).git.httpsUrl;
|
).git.httpsUrl;
|
||||||
|
|
||||||
var deployScript = ""
|
let deployScript = ""
|
||||||
+ "cd " + paths.docsDir + " "
|
+ "cd " + paths.docsDir + " "
|
||||||
+ "&& git init " + "> /dev/null 2>&1 "
|
+ "&& git init " + "> /dev/null 2>&1 "
|
||||||
+ "&& git config user.name \"TRAVIS CI\" " + "> /dev/null 2>&1 "
|
+ "&& git config user.name \"TRAVIS CI\" " + "> /dev/null 2>&1 "
|
||||||
@ -40,28 +40,25 @@ var publishDocs = function(configArg){
|
|||||||
+ "\"" + gitUrl + "\" "
|
+ "\"" + gitUrl + "\" "
|
||||||
+ "master:gh-pages " + "> /dev/null 2>&1";
|
+ "master:gh-pages " + "> /dev/null 2>&1";
|
||||||
|
|
||||||
if(plugins.smartenv.getEnv().isTravis && configArg.docs && configArg.docs.publish){
|
|
||||||
plugins.beautylog.log("now publishing docs to GitHub");
|
plugins.beautylog.log("now publishing JsDoc documentation to GitHub");
|
||||||
if (!plugins.shelljs.which('git')) {
|
if (!plugins.shelljs.which('git')) {
|
||||||
plugins.beautylog.error('Git is not installed!');
|
plugins.beautylog.error('Git is not installed!');
|
||||||
plugins.shelljs.exit(1);
|
plugins.shelljs.exit(1);
|
||||||
} else if (plugins.shelljs.exec(deployScript).code !== 0) {
|
} else if (plugins.shelljs.exec(deployScript).code !== 0) {
|
||||||
plugins.beautylog.error('Git failed!');
|
plugins.beautylog.error('Git failed!');
|
||||||
plugins.shelljs.exit(1);
|
plugins.shelljs.exit(1);
|
||||||
}
|
|
||||||
plugins.beautylog.ok("JsDoc has been deployed to GitHub!");
|
|
||||||
done.resolve(configArg);
|
|
||||||
} else {
|
|
||||||
done.resolve(configArg);
|
|
||||||
}
|
}
|
||||||
|
plugins.beautylog.ok("JsDoc documentation has been deployed to GitHub!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export var run = function(configArg){
|
export let run = function(configArg){
|
||||||
var done = plugins.Q.defer();
|
let done = plugins.Q.defer();
|
||||||
genJsdoc(configArg)
|
genJsdoc(configArg)
|
||||||
.then(publishDocs)
|
|
||||||
.then(done.resolve);
|
.then(done.resolve);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
@ -1,11 +1,27 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
import plugins = require("./npmts.plugins");
|
import plugins = require("./npmts.plugins");
|
||||||
|
|
||||||
|
export let isCi = function(){
|
||||||
|
return plugins.smartci.check.isCi();
|
||||||
|
};
|
||||||
|
|
||||||
|
export let isRelease = function():boolean {
|
||||||
|
return plugins.smartci.check.isCi()
|
||||||
|
&& plugins.smartci.check.isTaggedCommit();
|
||||||
|
};
|
||||||
|
|
||||||
|
export let doPublish = function():boolean {
|
||||||
|
return isRelease()
|
||||||
|
&& plugins.smartci.get.subJobNumber() == 1;
|
||||||
|
};
|
||||||
|
|
||||||
export var run = function(configArg){
|
export var run = function(configArg){
|
||||||
var done = plugins.Q.defer();
|
var done = plugins.Q.defer();
|
||||||
var config = configArg;
|
var config = configArg;
|
||||||
if (typeof config.coveralls === "undefined"){
|
|
||||||
config.coveralls = false;
|
plugins.beautylog.log("now determining build options...");
|
||||||
}
|
|
||||||
|
//handle default mode
|
||||||
if (config.mode == "default"){
|
if (config.mode == "default"){
|
||||||
config.typings = [
|
config.typings = [
|
||||||
"./ts/typings.json"
|
"./ts/typings.json"
|
||||||
@ -15,9 +31,30 @@ export var run = function(configArg){
|
|||||||
["./test/test.ts"]: "./test/"
|
["./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 = {};
|
||||||
|
|
||||||
|
// handle state of current build
|
||||||
|
|
||||||
|
isRelease() ? plugins.beautylog.info("All right: This is a RELEASE build!")
|
||||||
|
: plugins.beautylog.info("NOT A RELEASE build!");
|
||||||
|
isRelease() && doPublish() ? plugins.beautylog.info("All right: This is the first subBuild, so this one publishes COVERAGE + DOCS when tests succeed!")
|
||||||
|
: plugins.beautylog.info("We are not publishing anything!");
|
||||||
|
|
||||||
|
// handle coveralls
|
||||||
|
config.codecov ? void(0) : config.codecov = true;
|
||||||
|
isCi() ? void(0) : config.codecov = false;
|
||||||
|
|
||||||
|
config.coverageTreshold ? void(0) : config.coverageTreshold = 70;
|
||||||
|
|
||||||
|
// handle docs
|
||||||
|
config.docs ? void(0) : config.docs = {};
|
||||||
|
config.docs.publish ? void(0) : config.docs.publish = false;
|
||||||
|
doPublish() ? void(0) : config.docs.publish = false;
|
||||||
|
|
||||||
|
plugins.beautylog.ok("build options are ready!");
|
||||||
|
done.resolve(config);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
@ -8,6 +8,7 @@ paths.tsDir = plugins.path.join(paths.cwd,"ts/");
|
|||||||
paths.distDir = plugins.path.join(paths.cwd,"dist/");
|
paths.distDir = plugins.path.join(paths.cwd,"dist/");
|
||||||
paths.docsDir = plugins.path.join(paths.cwd,"docs/");
|
paths.docsDir = plugins.path.join(paths.cwd,"docs/");
|
||||||
paths.testDir = plugins.path.join(paths.cwd,"test/");
|
paths.testDir = plugins.path.join(paths.cwd,"test/");
|
||||||
|
paths.coverageDir = plugins.path.join(paths.cwd,"coverage/");
|
||||||
|
|
||||||
paths.npmtsAssetsDir = plugins.path.join(__dirname,"../assets/");
|
paths.npmtsAssetsDir = plugins.path.join(__dirname,"../assets/");
|
||||||
|
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
var plugins = {
|
export let beautylog = require("beautylog");
|
||||||
beautylog: require("beautylog"),
|
export let fs = require("fs-extra");
|
||||||
fs: require("fs-extra"),
|
export let gulp = require("gulp");
|
||||||
gulp: require("gulp"),
|
export let g = {
|
||||||
g: {
|
codecov: require("gulp-codecov"),
|
||||||
coveralls: require("gulp-coveralls"),
|
gFunction: require("gulp-function"),
|
||||||
gFunction: require("gulp-function"),
|
istanbul: require("gulp-istanbul"),
|
||||||
istanbul: require("gulp-istanbul"),
|
jsdoc3: require("gulp-jsdoc3"),
|
||||||
jsdoc3: require("gulp-jsdoc3"),
|
mocha: require("gulp-mocha"),
|
||||||
mocha: require("gulp-mocha"),
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
sourcemaps: require("gulp-sourcemaps"),
|
typescript: require("gulp-typescript"),
|
||||||
typescript: require("gulp-typescript"),
|
typings: require("gulp-typings")
|
||||||
typings: require("gulp-typings")
|
|
||||||
|
|
||||||
},
|
|
||||||
merge2: require("merge2"),
|
|
||||||
projectinfo: require("projectinfo"),
|
|
||||||
sourceMapSupport:require("source-map-support").install(),
|
|
||||||
path: require("path"),
|
|
||||||
Q:require("q"),
|
|
||||||
shelljs: require("shelljs"),
|
|
||||||
smartcli: require("smartcli"),
|
|
||||||
smartenv: require("smartenv"),
|
|
||||||
smartfile: require("smartfile"),
|
|
||||||
smartpath: require("smartpath")
|
|
||||||
};
|
};
|
||||||
export = plugins;
|
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 let smartci = require("smartci");
|
||||||
|
export let smartcli = require("smartcli");
|
||||||
|
export let smartcov = require("smartcov");
|
||||||
|
export let smartenv = require("smartenv");
|
||||||
|
export let smartfile = require("smartfile");
|
||||||
|
export let smartpath = require("smartpath");
|
||||||
|
export let sourceMapSupport = require("source-map-support").install(); // this is required to display errors correctly during testing
|
@ -2,22 +2,26 @@
|
|||||||
import plugins = require("./npmts.plugins");
|
import plugins = require("./npmts.plugins");
|
||||||
|
|
||||||
import NpmtsAssets = require("./npmts.assets");
|
import NpmtsAssets = require("./npmts.assets");
|
||||||
|
import NpmtsClean = require("./npmts.clean");
|
||||||
import NpmtsCompile = require("./npmts.compile");
|
import NpmtsCompile = require("./npmts.compile");
|
||||||
import NpmtsConfigFile = require("./npmts.configfile");
|
import NpmtsConfigFile = require("./npmts.configfile");
|
||||||
import NpmtsInstall = require("./npmts.install");
|
import NpmtsInstall = require("./npmts.install");
|
||||||
import NpmtsJsdoc = require("./npmts.jsdoc");
|
import NpmtsJsdoc = require("./npmts.jsdoc");
|
||||||
import NpmtsOptions = require("./npmts.options");
|
import NpmtsOptions = require("./npmts.options");
|
||||||
|
import NpmtsPublish = require("./npmts.publish");
|
||||||
import NpmtsTests = require("./npmts.tests");
|
import NpmtsTests = require("./npmts.tests");
|
||||||
|
|
||||||
export var run = function(){
|
export var run = function(){
|
||||||
var promisechain;
|
var promisechain;
|
||||||
NpmtsConfigFile.run()
|
NpmtsConfigFile.run()
|
||||||
.then(NpmtsOptions.run)
|
.then(NpmtsOptions.run)
|
||||||
|
.then(NpmtsClean.run)
|
||||||
.then(NpmtsInstall.run)
|
.then(NpmtsInstall.run)
|
||||||
.then(NpmtsCompile.run)
|
.then(NpmtsCompile.run)
|
||||||
.then(NpmtsAssets.run)
|
.then(NpmtsAssets.run)
|
||||||
.then(NpmtsJsdoc.run)
|
.then(NpmtsJsdoc.run)
|
||||||
.then(NpmtsTests.run)
|
.then(NpmtsTests.run)
|
||||||
|
.then(NpmtsPublish.run)
|
||||||
.then(function(configArg){
|
.then(function(configArg){
|
||||||
let shipString = "" +
|
let shipString = "" +
|
||||||
"\n" +
|
"\n" +
|
||||||
@ -36,6 +40,8 @@ export var run = function(){
|
|||||||
if (process.env.CI){
|
if (process.env.CI){
|
||||||
console.log(shipString);
|
console.log(shipString);
|
||||||
plugins.beautylog.success("READY TO SHIP!");
|
plugins.beautylog.success("READY TO SHIP!");
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.success("Done!")
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
18
ts/npmts.publish.ts
Normal file
18
ts/npmts.publish.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
import NpmtsTests = require("./npmts.tests");
|
||||||
|
import NpmtsJsdoc = require("./npmts.jsdoc");
|
||||||
|
|
||||||
|
|
||||||
|
export let run = function(configArg){
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let config = configArg;
|
||||||
|
let promiseArray = [];
|
||||||
|
config.codecov ? promiseArray.push(NpmtsTests.publishCoverage(configArg)) : void(0);
|
||||||
|
config.docs.publish ? promiseArray.push(NpmtsJsdoc.publishDocs(configArg)) : void(0);
|
||||||
|
promiseArray.length === 0 ? plugins.beautylog.info("Did not publish anything!") : void(0);
|
||||||
|
|
||||||
|
plugins.Q.all(promiseArray).then(done.resolve);
|
||||||
|
return done.promise;
|
||||||
|
};
|
@ -1,50 +1,88 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
import plugins = require("./npmts.plugins");
|
import plugins = require("./npmts.plugins");
|
||||||
import paths = require("./npmts.paths");
|
import paths = require("./npmts.paths");
|
||||||
export var run = function(configArg) {
|
|
||||||
var done = plugins.Q.defer();
|
|
||||||
var config = configArg;
|
|
||||||
var istanbul = function () {
|
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
|
|
||||||
// Covering files
|
|
||||||
.pipe(plugins.g.istanbul())
|
|
||||||
// Force `require` to return covered files
|
|
||||||
.pipe(plugins.g.istanbul.hookRequire());
|
|
||||||
return stream;
|
|
||||||
};
|
|
||||||
|
|
||||||
var mocha = function () {
|
export let publishCoverage = function(configArg){
|
||||||
var stream = plugins.gulp.src(["./test/test.js"])
|
let done = plugins.Q.defer();
|
||||||
.pipe(plugins.g.mocha())
|
plugins.beautylog.log("now uploading coverage data to codecov.io");
|
||||||
// Creating the reports after tests ran
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
|
||||||
.pipe(plugins.g.istanbul.writeReports())
|
.pipe(plugins.g.codecov())
|
||||||
// Enforce a coverage of at least 90%
|
.pipe(plugins.g.gFunction(function(){
|
||||||
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
plugins.beautylog.ok("Coverage data has been uploaded to codecov.io!");
|
||||||
return stream;
|
done.resolve(configArg);
|
||||||
};
|
},"atEnd"));
|
||||||
|
return done.promise;
|
||||||
var coveralls = function(){
|
};
|
||||||
plugins.beautylog.log("now uploading coverage data to coveralls");
|
|
||||||
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"./coverage/lcov.info")])
|
/**
|
||||||
.pipe(plugins.g.coveralls())
|
*
|
||||||
.pipe(plugins.g.gFunction(function(){
|
* @returns {*}
|
||||||
plugins.beautylog.ok("Tests have passed and coverage data has been uploaded to Coveralls!");
|
*/
|
||||||
},"atEnd"));
|
let istanbul = function (configArg) {
|
||||||
return stream;
|
let done = plugins.Q.defer();
|
||||||
};
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
|
||||||
|
.pipe(plugins.g.istanbul()) // Covering files
|
||||||
plugins.beautylog.log("now starting tests");
|
.pipe(plugins.g.istanbul.hookRequire()) // Force `require` to return covered files
|
||||||
istanbul().on("finish",function(){
|
.pipe(plugins.g.gFunction(function(){
|
||||||
mocha().on("finish",function(){
|
done.resolve(configArg);
|
||||||
if(plugins.smartenv.getEnv().isTravis && config.coveralls){
|
},"atEnd"));
|
||||||
coveralls().on("finish",function(){
|
return done.promise;
|
||||||
done.resolve(config);
|
};
|
||||||
})
|
|
||||||
} else {
|
/**
|
||||||
plugins.beautylog.ok("Tests have passed!");
|
*
|
||||||
done.resolve(config);
|
* @returns {*}
|
||||||
}
|
*/
|
||||||
})
|
let mocha = function (configArg) {
|
||||||
});
|
let done = plugins.Q.defer();
|
||||||
|
let stream = plugins.gulp.src(["./test/test.js"])
|
||||||
|
.pipe(plugins.g.mocha())
|
||||||
|
.pipe(plugins.g.istanbul.writeReports()) // Creating the reports after tests ran
|
||||||
|
.pipe(plugins.g.gFunction(function(){
|
||||||
|
plugins.beautylog.ok("Tests have passed!");
|
||||||
|
done.resolve(configArg);
|
||||||
|
},"atEnd"));
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
let coverage = function(configArg){
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
plugins.smartcov.get.percentage(plugins.path.join(paths.coverageDir,"lcov.info"))
|
||||||
|
.then(function(percentageArg){
|
||||||
|
if (percentageArg >= configArg.coverageTreshold){
|
||||||
|
plugins.beautylog.ok(
|
||||||
|
"your coverage of " + percentageArg.toString().blue + "% ".blue + "exceeds your treshold of " +
|
||||||
|
configArg.coverageTreshold.toString().blue + "%".blue
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.warn(
|
||||||
|
"your coverage of " + percentageArg + "% " + "fails your treshold of " +
|
||||||
|
configArg.coverageTreshold + "%"
|
||||||
|
);
|
||||||
|
plugins.beautylog.error("exiting due to coverage failure");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
export let run = function(configArg) {
|
||||||
|
let done = plugins.Q.defer();
|
||||||
|
let config = configArg;
|
||||||
|
|
||||||
|
plugins.beautylog.log("now starting tests");
|
||||||
|
console.log(
|
||||||
|
"--------------------------------------------------------------\n" +
|
||||||
|
"***************************" +
|
||||||
|
" TESTS: ".blue +
|
||||||
|
"***************************\n" +
|
||||||
|
"--------------------------------------------------------------"
|
||||||
|
);
|
||||||
|
|
||||||
|
istanbul(config)
|
||||||
|
.then(mocha)
|
||||||
|
.then(coverage)
|
||||||
|
.then(done.resolve);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"ambientDependencies": {
|
"ambientDependencies": {
|
||||||
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user