Compare commits
113 Commits
Author | SHA1 | Date | |
---|---|---|---|
db63e07fa3 | |||
be65ee65cb | |||
78bbe2d1d7 | |||
3960cd9973 | |||
0bad43d726 | |||
d5407e33dd | |||
2035045aef | |||
de0f8cfb8b | |||
fe7d2f1024 | |||
9f0343b01c | |||
04a02f6b96 | |||
cb3f343c92 | |||
6227e47037 | |||
2730ca4299 | |||
07aae64965 | |||
56841d5bb0 | |||
40301ede35 | |||
70213b04bc | |||
5160aab180 | |||
e8806e548b | |||
fcdaad540e | |||
6f33b1f5ef | |||
45418d6049 | |||
4261ee3687 | |||
9fc3606163 | |||
2436b30605 | |||
9ad59704be | |||
29f3832d63 | |||
2d82a3a037 | |||
4806f5ceff | |||
f2ef982189 | |||
5d6ead017b | |||
1c2b4e421d | |||
6cf7d2ca0b | |||
676c072631 | |||
f29c04e09c | |||
77a06a0fc4 | |||
c9792b1955 | |||
b87de178c0 | |||
0580f29d30 | |||
2c17273671 | |||
669ed2e6ab | |||
8bc73b2bf4 | |||
78e5defd7c | |||
7e540bda87 | |||
b293dfe92d | |||
a753a5db2c | |||
27f79b4425 | |||
1ada5dd5a9 | |||
a41bfd442c | |||
2917b10ffb | |||
bfc5bbbbb7 | |||
cf507a4a17 | |||
73a57ed264 | |||
39b79b679c | |||
cc053ee396 | |||
df5371187b | |||
cbda76c380 | |||
e20bcec133 | |||
3e673e04b2 | |||
2090dad540 | |||
ebe7a02ef0 | |||
3f9194f344 | |||
13c9c96cc6 | |||
3f0b2b1599 | |||
d477e492eb | |||
f39cb03fc2 | |||
f42744b927 | |||
038994e9e5 | |||
7a26721420 | |||
0dc307f082 | |||
4b2c0fe461 | |||
50fd5e83ad | |||
3e55a666b2 | |||
5d8ce3f227 | |||
de4bbaed9f | |||
7d18e92ff1 | |||
634763c03f | |||
3352165436 | |||
6c57a4703f | |||
822734e545 | |||
8dcbe98c60 | |||
2fbcb58078 | |||
362f8d5388 | |||
8fb4a60fb3 | |||
7c6b5afd5f | |||
f83eb035c2 | |||
359e844c69 | |||
6b40cfd954 | |||
8f13dbef9f | |||
9ff2453d7b | |||
e40a82e8c9 | |||
cac50f7099 | |||
ef64874411 | |||
870d24701c | |||
d12a09d3d8 | |||
2a4811ccb0 | |||
146b9cf683 | |||
9110a6701d | |||
3101af3726 | |||
20283c6cda | |||
814542e9cd | |||
bea8a50f0b | |||
d18dc73522 | |||
6bf81fc665 | |||
a9a23687e9 | |||
e50a86439b | |||
ee69817038 | |||
ef314f5b2d | |||
24f9e5e982 | |||
660942e798 | |||
f5bc4578d7 | |||
2a87fc839d |
11
.gitignore
vendored
11
.gitignore
vendored
@ -1,4 +1,13 @@
|
|||||||
.idea/
|
.idea/
|
||||||
.c9/
|
.c9/
|
||||||
node_modules/
|
node_modules/
|
||||||
test/node_modules
|
test/**/node_modules/
|
||||||
|
test/assets/docs/
|
||||||
|
test/**/typings/
|
||||||
|
test/**/coverage/
|
||||||
|
ts/*.js
|
||||||
|
ts/*.js.map
|
||||||
|
ts/typings/
|
||||||
|
docs/
|
||||||
|
|
||||||
|
.DS_Store
|
@ -1,5 +1,6 @@
|
|||||||
|
.idea/
|
||||||
support
|
support
|
||||||
compile
|
compile
|
||||||
test
|
test/
|
||||||
examples
|
examples
|
||||||
.gitignore
|
.gitignore
|
12
.travis.yml
Normal file
12
.travis.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- "4.3.1"
|
||||||
|
- "stable"
|
||||||
|
deploy:
|
||||||
|
provider: npm
|
||||||
|
email: npm@lossless.digital
|
||||||
|
api_key:
|
||||||
|
secure: k075QdAcmEdmAoVaP5vclLnZmhbZB39v85VIUMWAKXbIAU+liHrYZRlIEYfAaIUrf6sha+zAo/U/vjAN7c5ArB7J/HjCLJ3lsi2fWtaSRlYQrYX9/EhU0S+YZjRE8Jrn4hGTcce6I2mANBnEzvzlXrlKaqVvSqOqTO9nJ5aDBCGa5XT3EwlHKkRlAlL3ZOLrRg38R343E8ifZBsbn9G0e+RgDt0sic3WD8NME9lpsQ/99UZKH00duHbhF9nme5Sjdh86y01hvsaBf+CLR4gfS2IntnrCSrZbETFrsOBUyMnJZDQ3qlrjcEaiTkpJ4iSIqr+ftwGMMD6S1MxCTPqkp64UIeMz2Tg41HqoaeIg7z8cF0APv6M9ZAdWhsU43GqsMe70dK900JZpQAkQxMf/6NpPpGfZug6TwqLYSIRzvjvNrhYfuyoGfXdAxrM3SJMkIq6rwE+T/y36kZaC3CrQRyNZypNz0vW1M9HLjJUi2vO0U/CDn8tvi1p6ChrDXDfV3H2UIAMHFlAF+GrT7dMWwD+p+d8mc9gpAFEF9zMqAIJamPhwboJxoHjKQrqrq5czNm75ETL77AzfnU6CfQlG5dTIFnGId8y0ZxXvtpBruDoyC1+ZF23MYZmb+ipxQZM2oLCjNLeL3aEePc/JlSm6Gn8w3sIkZTG261F0XZxdApw=
|
||||||
|
on:
|
||||||
|
tags: true
|
||||||
|
repo: pushrocks/npmts
|
1
README-dev.md
Normal file
1
README-dev.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# README-dev
|
97
README.md
Normal file
97
README.md
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
# npmts
|
||||||
|
Write npm modules with TypeScript without hassle.
|
||||||
|
|
||||||
|
## Status
|
||||||
|
[](https://travis-ci.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)
|
||||||
|
[](https://coveralls.io/github/pushrocks/npmts?branch=master)
|
||||||
|
|
||||||
|
## How to use npmts
|
||||||
|
|
||||||
|
### Install
|
||||||
|
First install npmts as dev dependency:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install npmts --save-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Then use it in package.json's script section to trigger a build:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"scripts": {
|
||||||
|
"test": "npmts"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Default behaviour
|
||||||
|
|
||||||
|
**Execution order of tasks**
|
||||||
|
|
||||||
|
1. Install typings
|
||||||
|
2. Transpile TypeScript with inline sourcemaps
|
||||||
|
3. Create Declaration Files
|
||||||
|
4. Instrumentalize created JavaScript files with istanbul
|
||||||
|
5. Run Tests
|
||||||
|
6. Create Coverage report
|
||||||
|
7. Upload Coverage reports to travis (must be activated, only triggers on travis)
|
||||||
|
|
||||||
|
|
||||||
|
#### 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.
|
||||||
|
|
||||||
|
#### TypeScript
|
||||||
|
by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
|
||||||
|
`./dist/*.js` and `./test/test.js`
|
||||||
|
|
||||||
|
Use commonjs module system for wiring up files.
|
||||||
|
|
||||||
|
#### Declaration files
|
||||||
|
**npmts** also creates an `index.d.ts` declaration file by default.
|
||||||
|
You can reference it in your package.json like this:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"main": "index.js",
|
||||||
|
"typings": "./index.d.ts",
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Instrumentalize Code
|
||||||
|
npmts instrumentalizes the created JavaScript code to create a coverage report.
|
||||||
|
|
||||||
|
#### Tests
|
||||||
|
When Typings have been installed, TypeScript + Declaration files have been transpiled and the resulting JS has been instrumentalized,
|
||||||
|
npmts runs `.test/test.js` with mocha.
|
||||||
|
|
||||||
|
Any errors will be shown with reference to their originating source in TypeScript.
|
||||||
|
|
||||||
|
When requiring the module from other TypeScript files,
|
||||||
|
the TypeScript Compiler will use the declaration file to resolve typings.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Custom behaviour
|
||||||
|
Custom behaviour can be achieved through a config file at the root of your package.
|
||||||
|
The file must be named **npmts.json**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"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.
|
1
assets/node-shebang.js
Normal file
1
assets/node-shebang.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
#!/usr/bin/env node
|
@ -1,25 +1,39 @@
|
|||||||
// import gulp
|
// import gulp
|
||||||
var gulp = require("gulp");
|
|
||||||
var gulpTypescript = require("gulp-typescript");
|
|
||||||
var gulpInsert = require("gulp-insert");
|
|
||||||
var plugins = {
|
var plugins = {
|
||||||
beautylog: require("beautylog")
|
beautylog: require("beautylog"),
|
||||||
|
gulp: require("gulp"),
|
||||||
|
g:{
|
||||||
|
typescript: require("gulp-typescript"),
|
||||||
|
header: require("gulp-header")
|
||||||
|
},
|
||||||
|
mergeStream: require("merge2"),
|
||||||
|
path: require("path")
|
||||||
};
|
};
|
||||||
|
|
||||||
plugins.beautylog.log('now compiling the mojo.io gulp tasks');
|
paths = {
|
||||||
|
packageBase: plugins.path.resolve(
|
||||||
|
plugins.path.join(__dirname,"../")
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
gulp.task('indexTS', function() {
|
plugins.beautylog.log('now compiling NPMTS');
|
||||||
var stream = gulp.src('../ts/index.ts')
|
|
||||||
.pipe(gulpTypescript({
|
plugins.gulp.task('indexTS', function() {
|
||||||
out: "index.js"
|
var stream = plugins.gulp.src([
|
||||||
}))
|
plugins.path.join(paths.packageBase,'ts/**/*.ts'),
|
||||||
.pipe(gulpInsert.prepend('#!/usr/bin/env node\n\n'))
|
"!" + plugins.path.join(paths.packageBase,'ts/typings/**/*.d.ts')
|
||||||
.pipe(gulp.dest("../"));
|
])
|
||||||
return stream;
|
.pipe(plugins.g.typescript({
|
||||||
|
target:"ES5",
|
||||||
|
module:"commonjs"
|
||||||
|
}))
|
||||||
|
.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
|
||||||
|
.pipe(plugins.gulp.dest(plugins.path.join(paths.packageBase, 'dist/')));
|
||||||
|
return stream;
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('default',['indexTS'], function() {
|
plugins.gulp.task('default',['indexTS'], function() {
|
||||||
plugins.beautylog.success('Typescript compiled');
|
plugins.beautylog.success('Typescript compiled');
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.start.apply(gulp, ['default']);
|
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
3
dist/cli.js
vendored
Normal file
3
dist/cli.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
8
dist/index.js
vendored
Normal file
8
dist/index.js
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
console.log("**** starting NPMTS ****");
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var promisechain = require("./npmts.promisechain");
|
||||||
|
plugins.beautylog.figletSync("NPMTS");
|
||||||
|
promisechain.run();
|
3
dist/npmts.cli.js
vendored
Normal file
3
dist/npmts.cli.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
91
dist/npmts.compile.js
vendored
Normal file
91
dist/npmts.compile.js
vendored
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
plugins.beautylog.log("now running custom tasks");
|
||||||
|
var moduleStream = plugins.merge2({ end: false });
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- first install typings ---------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
var typingsDone = plugins.Q.defer();
|
||||||
|
var typingsCounter = 0;
|
||||||
|
var typingsCounterAdvance = function () {
|
||||||
|
typingsCounter++;
|
||||||
|
if (typeof config.typings[typingsCounter] != "undefined") {
|
||||||
|
installTypings();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugins.beautylog.success("custom typings installed successfully");
|
||||||
|
typingsDone.resolve();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var installTypings = function () {
|
||||||
|
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
|
||||||
|
plugins.typings.install({ production: false, cwd: plugins.path.join(paths.cwd, config.typings[typingsCounter]) })
|
||||||
|
.then(function () {
|
||||||
|
typingsCounterAdvance();
|
||||||
|
}, function () {
|
||||||
|
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
|
||||||
|
typingsCounterAdvance();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
installTypings();
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- second compile TS -------------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
typingsDone.promise.then(function () {
|
||||||
|
for (var key in config.ts) {
|
||||||
|
plugins.beautylog.log("now compiling" + key.blue);
|
||||||
|
var outputPathIsDir;
|
||||||
|
try {
|
||||||
|
if (plugins.fs.statSync(plugins.path.join(paths.cwd, config.ts[key])).isDirectory()) {
|
||||||
|
outputPathIsDir = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
outputPathIsDir = false;
|
||||||
|
}
|
||||||
|
//do some evaluation of the environment
|
||||||
|
var outputNameSpecified = (!outputPathIsDir
|
||||||
|
&& (plugins.path.extname(config.ts[key]) == ".js"));
|
||||||
|
var outputName = (function () {
|
||||||
|
if (outputNameSpecified) {
|
||||||
|
return plugins.path.basename(config.ts[key]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
var outputDir = (function () {
|
||||||
|
if (outputNameSpecified) {
|
||||||
|
return plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return plugins.path.join(paths.cwd, config.ts[key]);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, key), "!**/typings/**"])
|
||||||
|
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out: outputName,
|
||||||
|
target: "ES5",
|
||||||
|
module: "commonjs"
|
||||||
|
}))
|
||||||
|
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||||
|
.pipe(plugins.gulp.dest(outputDir));
|
||||||
|
moduleStream.add(stream);
|
||||||
|
}
|
||||||
|
moduleStream.on("queueDrain", function () {
|
||||||
|
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||||
|
moduleStream.on("finish", function () {
|
||||||
|
done.resolve(config);
|
||||||
|
});
|
||||||
|
moduleStream.end();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
31
dist/npmts.configfile.js
vendored
Normal file
31
dist/npmts.configfile.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
exports.run = function () {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = {};
|
||||||
|
var configPath = plugins.path.join(paths.cwd, "npmts.json");
|
||||||
|
if (plugins.smartfile.checks.fileExistsSync(configPath)) {
|
||||||
|
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
||||||
|
config = plugins.smartfile.readFileToObject(configPath);
|
||||||
|
switch (config.mode) {
|
||||||
|
case "default":
|
||||||
|
case "custom":
|
||||||
|
plugins.beautylog.log("mode is " + config.mode.yellow);
|
||||||
|
done.resolve(config);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
||||||
|
config.mode = "default";
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
return done.promise;
|
||||||
|
};
|
64
dist/npmts.jsdoc.js
vendored
Normal file
64
dist/npmts.jsdoc.js
vendored
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
var genJsdoc = function () {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
plugins.beautylog.log("now generating " + "JsDoc documentation".blue);
|
||||||
|
plugins.gulp.src([
|
||||||
|
plugins.path.join(paths.cwd, "README.md"),
|
||||||
|
plugins.path.join(paths.distDir, "**/*.js")
|
||||||
|
])
|
||||||
|
.pipe(plugins.g.jsdoc3({
|
||||||
|
opts: {
|
||||||
|
destination: paths.docsDir
|
||||||
|
}
|
||||||
|
}, done.resolve));
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
var publishDocs = function () {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
try {
|
||||||
|
var gitUrl = plugins.projectinfo.npm(paths.cwd, {
|
||||||
|
gitAccessToken: process.env.GITHUB_TOKEN
|
||||||
|
}).git.httpsUrl;
|
||||||
|
var deployScript = ""
|
||||||
|
+ "cd " + paths.docsDir + " "
|
||||||
|
+ "&& git init "
|
||||||
|
+ "&& git config user.name \"TRAVIS CI\" "
|
||||||
|
+ "&& git config user.email \"travis@shipzone.io\" "
|
||||||
|
+ "&& git add . "
|
||||||
|
+ "&& git commit -m \"Deploy to GitHub Pages\" "
|
||||||
|
+ "&& git push --force --quiet "
|
||||||
|
+ "\"" + gitUrl + "\" "
|
||||||
|
+ "master:gh-pages "
|
||||||
|
+ "> /dev/null 2>&1";
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
if (plugins.smartenv.getEnv().isTravis) {
|
||||||
|
plugins.beautylog.log("now publishing docs 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('Error: Git failed');
|
||||||
|
plugins.shelljs.exit(1);
|
||||||
|
}
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
exports.run = function () {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
genJsdoc()
|
||||||
|
.then(publishDocs)
|
||||||
|
.then(done.resolve);
|
||||||
|
return done.promise;
|
||||||
|
};
|
28
dist/npmts.options.js
vendored
Normal file
28
dist/npmts.options.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
if (typeof config.coveralls === "undefined") {
|
||||||
|
config.coveralls = false;
|
||||||
|
}
|
||||||
|
if (config.mode == "default") {
|
||||||
|
config.typings = [
|
||||||
|
"./ts/"
|
||||||
|
];
|
||||||
|
config.ts = (_a = {},
|
||||||
|
_a["./ts/**/*.ts"] = "./dist/",
|
||||||
|
_a["./test/test.ts"] = "./test/",
|
||||||
|
_a
|
||||||
|
);
|
||||||
|
config.test = ["./index.js"];
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
var _a;
|
||||||
|
};
|
15
dist/npmts.paths.js
vendored
Normal file
15
dist/npmts.paths.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = {};
|
||||||
|
paths.cwd = plugins.smartcli.get.cwd().path;
|
||||||
|
//Directories
|
||||||
|
paths.tsDir = plugins.path.join(paths.cwd, "ts/");
|
||||||
|
paths.distDir = plugins.path.join(paths.cwd, "dist/");
|
||||||
|
paths.docsDir = plugins.path.join(paths.cwd, "docs/");
|
||||||
|
paths.testDir = plugins.path.join(paths.cwd, "test/");
|
||||||
|
//Files
|
||||||
|
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
||||||
|
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
|
||||||
|
module.exports = paths;
|
28
dist/npmts.plugins.js
vendored
Normal file
28
dist/npmts.plugins.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = {
|
||||||
|
beautylog: require("beautylog"),
|
||||||
|
fs: require("fs-extra"),
|
||||||
|
gulp: require("gulp"),
|
||||||
|
g: {
|
||||||
|
coveralls: require("gulp-coveralls"),
|
||||||
|
gFunction: require("gulp-function"),
|
||||||
|
istanbul: require("gulp-istanbul"),
|
||||||
|
jsdoc3: require("gulp-jsdoc3"),
|
||||||
|
mocha: require("gulp-mocha"),
|
||||||
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
|
typescript: require("gulp-typescript")
|
||||||
|
},
|
||||||
|
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"),
|
||||||
|
typings: require("typings")
|
||||||
|
};
|
||||||
|
module.exports = plugins;
|
17
dist/npmts.promisechain.js
vendored
Normal file
17
dist/npmts.promisechain.js
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var NpmtsConfigFile = require("./npmts.configfile");
|
||||||
|
var NpmtsOptions = require("./npmts.options");
|
||||||
|
var NpmtsCompile = require("./npmts.compile");
|
||||||
|
var NpmtsJsdoc = require("./npmts.jsdoc");
|
||||||
|
var NpmtsTests = require("./npmts.tests");
|
||||||
|
exports.run = function () {
|
||||||
|
var promisechain;
|
||||||
|
NpmtsConfigFile.run()
|
||||||
|
.then(NpmtsOptions.run)
|
||||||
|
.then(NpmtsCompile.run)
|
||||||
|
.then(NpmtsJsdoc.run)
|
||||||
|
.then(NpmtsTests.run);
|
||||||
|
return promisechain;
|
||||||
|
};
|
41
dist/npmts.tests.js
vendored
Normal file
41
dist/npmts.tests.js
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./npmts.plugins");
|
||||||
|
var paths = require("./npmts.paths");
|
||||||
|
exports.run = function (configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
var istanbul = function () {
|
||||||
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
|
||||||
|
.pipe(plugins.g.istanbul())
|
||||||
|
.pipe(plugins.g.istanbul.hookRequire());
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
var mocha = function () {
|
||||||
|
var stream = plugins.gulp.src(["./test/test.js"])
|
||||||
|
.pipe(plugins.g.mocha())
|
||||||
|
.pipe(plugins.g.istanbul.writeReports())
|
||||||
|
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
var coveralls = function () {
|
||||||
|
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());
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
istanbul().on("finish", function () {
|
||||||
|
mocha().on("finish", function () {
|
||||||
|
if (plugins.smartenv.getEnv().isTravis && config.coveralls) {
|
||||||
|
coveralls().on("finish", function () {
|
||||||
|
done.resolve(config);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
39
index.js
39
index.js
@ -1,39 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/// <reference path="./typings/tsd.d.ts" />
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
gulp: require("gulp"),
|
|
||||||
gulpTypeScript: require("gulp-typescript"),
|
|
||||||
path: require("path"),
|
|
||||||
smartcli: require("smartcli")
|
|
||||||
};
|
|
||||||
var paths = {};
|
|
||||||
paths.cwd = plugins.smartcli.get.cwd().path;
|
|
||||||
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
|
||||||
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
|
|
||||||
plugins.gulp.task("indexTS", function () {
|
|
||||||
plugins.gulp.src(paths.indexTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "index.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd));
|
|
||||||
});
|
|
||||||
plugins.gulp.task("indexTS", function () {
|
|
||||||
plugins.gulp.src(paths.indexTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "index.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd));
|
|
||||||
});
|
|
||||||
plugins.gulp.task("testTS", function () {
|
|
||||||
plugins.gulp.src(paths.testTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "test.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd));
|
|
||||||
});
|
|
||||||
plugins.gulp.task("default", ["indexTS", "testTS"], function () {
|
|
||||||
plugins.beautylog.success("TypeScript for this module was compiled successfully.");
|
|
||||||
});
|
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
|
42
package.json
42
package.json
@ -1,15 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "0.0.7",
|
"version": "3.2.0",
|
||||||
"description": "write npm modules with TypeScript",
|
"description": "write npm modules with TypeScript",
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"npmts": "index.js"
|
"npmts": "dist/cli.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(cd compile && node compile.js)",
|
"test": "(cd compile && node compile.js) && (cd test/assets && node ../../dist/index.js)",
|
||||||
"release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)",
|
"release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)"
|
||||||
"testm": "(cd test/ && npm update && npm test)"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -26,10 +25,31 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/npmts#readme",
|
"homepage": "https://github.com/pushrocks/npmts#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^2.0.2",
|
"beautylog": "3.1.2",
|
||||||
"gulp": "^3.9.0",
|
"fs-extra": "^0.26.5",
|
||||||
"gulp-insert": "^0.5.0",
|
"gulp": "3.9.1",
|
||||||
"gulp-typescript": "^2.10.0",
|
"gulp-concat": "^2.6.0",
|
||||||
"smartcli": "0.0.11"
|
"gulp-coveralls": "^0.1.4",
|
||||||
|
"gulp-function": "^1.1.1",
|
||||||
|
"gulp-header": "^1.7.1",
|
||||||
|
"gulp-if": "^2.0.0",
|
||||||
|
"gulp-istanbul": "^0.10.3",
|
||||||
|
"gulp-jsdoc3": "^0.2.0",
|
||||||
|
"gulp-mocha": "^2.2.0",
|
||||||
|
"gulp-sourcemaps": "^1.6.0",
|
||||||
|
"gulp-typescript": "2.11.0",
|
||||||
|
"gulp-typings": "1.1.0",
|
||||||
|
"merge2": "1.0.1",
|
||||||
|
"projectinfo": "1.0.1",
|
||||||
|
"q": "^1.4.1",
|
||||||
|
"shelljs": "^0.6.0",
|
||||||
|
"smartcli": "0.0.11",
|
||||||
|
"smartenv": "1.1.0",
|
||||||
|
"smartfile": "0.0.11",
|
||||||
|
"source-map-support": "^0.4.0",
|
||||||
|
"typings": "^0.6.8"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"gulp-header": "^1.7.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test/assets/customdir/custom.js
Normal file
2
test/assets/customdir/custom.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var hello = "hello";
|
||||||
|
//# sourceMappingURL=custom.js.map
|
1
test/assets/customdir/custom.js.map
Normal file
1
test/assets/customdir/custom.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"custom.js","sourceRoot":"","sources":["custom.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,OAAO,CAAC"}
|
1
test/assets/customdir/custom.ts
Normal file
1
test/assets/customdir/custom.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
var hello = "hello";
|
2
test/assets/customdir/tsfile1.js
Normal file
2
test/assets/customdir/tsfile1.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var something = "something";
|
||||||
|
//# sourceMappingURL=tsfile1.js.map
|
1
test/assets/customdir/tsfile1.js.map
Normal file
1
test/assets/customdir/tsfile1.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"tsfile1.js","sourceRoot":"","sources":["tsfile1.ts"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,WAAW,CAAC"}
|
1
test/assets/customdir/tsfile1.ts
Normal file
1
test/assets/customdir/tsfile1.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
var something = "something";
|
7
test/assets/customdir/typings.json
Normal file
7
test/assets/customdir/typings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||||
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
|
}
|
||||||
|
}
|
9
test/assets/dist/index.js
vendored
Normal file
9
test/assets/dist/index.js
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var testplugin = {
|
||||||
|
logSomething: function () {
|
||||||
|
console.log("only function executed");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
module.exports = testplugin;
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0QztBQUM1QyxJQUFJLFVBQVUsR0FBRztJQUNiLFlBQVksRUFBRTtRQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0osQ0FBQztBQUNGLE1BQU0sQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxudmFyIHRlc3RwbHVnaW4gPSB7XG4gICAgbG9nU29tZXRoaW5nOiBmdW5jdGlvbigpe1xuICAgICAgICBjb25zb2xlLmxvZyhcIm9ubHkgZnVuY3Rpb24gZXhlY3V0ZWRcIik7XG4gICAgfVxufTtcbm1vZHVsZS5leHBvcnRzID0gdGVzdHBsdWdpbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
13
test/assets/npmts.json
Normal file
13
test/assets/npmts.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"mode":"default",
|
||||||
|
"ts":{
|
||||||
|
"./customdir/*.ts":"./"
|
||||||
|
},
|
||||||
|
"typings":[
|
||||||
|
"./ts",
|
||||||
|
"./subts1/",
|
||||||
|
"./subts2/",
|
||||||
|
"./customdir"
|
||||||
|
],
|
||||||
|
"coveralls":true
|
||||||
|
}
|
16
test/assets/package.json
Normal file
16
test/assets/package.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"name": "testpackage",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/sometest/somerepo.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "(npmts)"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
7
test/assets/subts1/typings.json
Normal file
7
test/assets/subts1/typings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||||
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
|
}
|
||||||
|
}
|
BIN
test/assets/test/.DS_Store
vendored
Normal file
BIN
test/assets/test/.DS_Store
vendored
Normal file
Binary file not shown.
2
test/assets/test/test.d.ts
vendored
Normal file
2
test/assets/test/test.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
|
declare var testplugin: any;
|
12
test/assets/test/test.js
Normal file
12
test/assets/test/test.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
|
console.log("**** starting test ****");
|
||||||
|
var testplugin = require("../dist/index.js");
|
||||||
|
describe("testplugins", function () {
|
||||||
|
describe(".logSomething", function () {
|
||||||
|
it("should log something", function () {
|
||||||
|
testplugin.logSomething();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELE9BQU8sQ0FBQyxHQUFHLENBQUMseUJBQXlCLENBQUMsQ0FBQztBQUN2QyxJQUFJLFVBQVUsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQztBQUM3QyxRQUFRLENBQUMsYUFBYSxFQUFDO0lBQ25CLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsRUFBRSxDQUFDLHNCQUFzQixFQUFDO1lBQ3RCLFVBQVUsQ0FBQyxZQUFZLEVBQUUsQ0FBQTtRQUM3QixDQUFDLENBQUMsQ0FBQztJQUNQLENBQUMsQ0FBQyxDQUFDO0FBQ1AsQ0FBQyxDQUFDLENBQUMiLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuLi90cy90eXBpbmdzL21haW4uZC50c1wiIC8+XG5jb25zb2xlLmxvZyhcIioqKiogc3RhcnRpbmcgdGVzdCAqKioqXCIpO1xudmFyIHRlc3RwbHVnaW4gPSByZXF1aXJlKFwiLi4vZGlzdC9pbmRleC5qc1wiKTtcbmRlc2NyaWJlKFwidGVzdHBsdWdpbnNcIixmdW5jdGlvbigpe1xuICAgIGRlc2NyaWJlKFwiLmxvZ1NvbWV0aGluZ1wiLGZ1bmN0aW9uKCl7XG4gICAgICAgIGl0KFwic2hvdWxkIGxvZyBzb21ldGhpbmdcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgdGVzdHBsdWdpbi5sb2dTb21ldGhpbmcoKVxuICAgICAgICB9KTtcbiAgICB9KTtcbn0pOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
1
test/assets/test/test.js.map
Normal file
1
test/assets/test/test.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,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"}
|
10
test/assets/test/test.ts
Normal file
10
test/assets/test/test.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
|
console.log("**** starting test ****");
|
||||||
|
var testplugin = require("../dist/index.js");
|
||||||
|
describe("testplugins",function(){
|
||||||
|
describe(".logSomething",function(){
|
||||||
|
it("should log something",function(){
|
||||||
|
testplugin.logSomething()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
8
test/assets/test/typings.json
Normal file
8
test/assets/test/typings.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||||
|
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||||
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
|
}
|
||||||
|
}
|
8
test/assets/ts/index.js
Normal file
8
test/assets/ts/index.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var testplugin = {
|
||||||
|
logSomething: function () {
|
||||||
|
console.log("only function executed");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
module.exports = testplugin;
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
test/assets/ts/index.js.map
Normal file
1
test/assets/ts/index.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,IAAI,UAAU,GAAG;IACb,YAAY,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAC;AACF,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC"}
|
7
test/assets/ts/index.ts
Normal file
7
test/assets/ts/index.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var testplugin = {
|
||||||
|
logSomething: function(){
|
||||||
|
console.log("only function executed");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
module.exports = testplugin;
|
8
test/assets/ts/typings.json
Normal file
8
test/assets/ts/typings.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||||
|
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||||
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
|
}
|
||||||
|
}
|
21
test/node_modules/npmts/LICENSE
generated
vendored
21
test/node_modules/npmts/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2016 Push.Rocks
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
43
test/node_modules/npmts/package.json
generated
vendored
43
test/node_modules/npmts/package.json
generated
vendored
@ -1,43 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "npmts",
|
|
||||||
"version": "0.0.6",
|
|
||||||
"description": "write npm modules with TypeScript",
|
|
||||||
"main": "index.js",
|
|
||||||
"bin": {
|
|
||||||
"npmts": "index.js"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "(cd compile && node compile.js)",
|
|
||||||
"release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)",
|
|
||||||
"testm": "(cd test/ && npm update && npm test)"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/pushrocks/npmts.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"TypeScript",
|
|
||||||
"Declaration"
|
|
||||||
],
|
|
||||||
"author": {
|
|
||||||
"name": "Lossless Digital UG",
|
|
||||||
"url": "haftungsbeschraenkt"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/pushrocks/npmts/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/pushrocks/npmts#readme",
|
|
||||||
"dependencies": {
|
|
||||||
"beautylog": "^2.0.2",
|
|
||||||
"gulp": "^3.9.0",
|
|
||||||
"gulp-insert": "^0.5.0",
|
|
||||||
"gulp-typescript": "^2.10.0",
|
|
||||||
"smartcli": "0.0.11"
|
|
||||||
},
|
|
||||||
"gitHead": "ea793f9556a074c20e945284b9b3c24af8e9b222",
|
|
||||||
"readme": "ERROR: No README data found!",
|
|
||||||
"_id": "npmts@0.0.6",
|
|
||||||
"_shasum": "6a9fe8963240a8443bb5cc152092ba9a0f929b70",
|
|
||||||
"_from": "npmts@0.0.6"
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "test",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "(npmts)"
|
|
||||||
},
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"npmts": "*"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
(function () {
|
|
||||||
console.log("test");
|
|
||||||
}());
|
|
@ -1,4 +0,0 @@
|
|||||||
(function () {
|
|
||||||
console.log("test");
|
|
||||||
}());
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,CAAC;IACG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACvB,CAAC,EAAE,CAAC,CAAC"}
|
|
@ -1,3 +0,0 @@
|
|||||||
(function(){
|
|
||||||
console.log("test")
|
|
||||||
}());
|
|
38
ts/index.js
38
ts/index.js
@ -1,38 +0,0 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
gulp: require("gulp"),
|
|
||||||
gulpTypeScript: require("gulp-typescript"),
|
|
||||||
path: require("path"),
|
|
||||||
smartcli: require("smartcli")
|
|
||||||
};
|
|
||||||
var paths = {};
|
|
||||||
paths.cwd = plugins.smartcli.get.cwd().path;
|
|
||||||
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
|
||||||
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
|
|
||||||
plugins.gulp.task("indexTS", function () {
|
|
||||||
plugins.gulp.src(paths.indexTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "index.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd));
|
|
||||||
});
|
|
||||||
plugins.gulp.task("indexTS", function () {
|
|
||||||
plugins.gulp.src(paths.indexTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "index.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd));
|
|
||||||
});
|
|
||||||
plugins.gulp.task("testTS", function () {
|
|
||||||
plugins.gulp.src(paths.testTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "test.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd));
|
|
||||||
});
|
|
||||||
plugins.gulp.task("default", ["indexTS", "testTS"], function () {
|
|
||||||
plugins.beautylog.success("TypeScript for this module was compiled successfully.");
|
|
||||||
});
|
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,IAAI,OAAO,GAAG;IACV,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAC1C,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC;CAChC,CAAC;AAEF,IAAI,KAAK,GAAO,EAAE,CAAC;AACnB,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;AAC5C,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAC,aAAa,CAAC,CAAC;AAC3D,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAC,YAAY,CAAC,CAAC;AAEzD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;IACzB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;SAC1B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QACzB,GAAG,EAAE,UAAU;KAClB,CAAC,CAAC;SACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;AAC3C,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;IACzB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;SAC1B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QACzB,GAAG,EAAE,UAAU;KAClB,CAAC,CAAC;SACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;AAC3C,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;IACxB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;SACzB,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QACzB,GAAG,EAAE,SAAS;KACjB,CAAC,CAAC;SACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;AAC3C,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,CAAC,SAAS,EAAC,QAAQ,CAAC,EAAC;IAC9C,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,uDAAuD,CAAC,CAAC;AACtF,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
|
49
ts/index.ts
49
ts/index.ts
@ -1,43 +1,6 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
var plugins = {
|
console.log("**** starting NPMTS ****");
|
||||||
beautylog: require("beautylog"),
|
import plugins = require("./npmts.plugins");
|
||||||
gulp: require("gulp"),
|
import promisechain = require("./npmts.promisechain");
|
||||||
gulpTypeScript: require("gulp-typescript"),
|
plugins.beautylog.figletSync("NPMTS");
|
||||||
path: require("path"),
|
promisechain.run();
|
||||||
smartcli: require("smartcli")
|
|
||||||
};
|
|
||||||
|
|
||||||
var paths:any = {};
|
|
||||||
paths.cwd = plugins.smartcli.get.cwd().path;
|
|
||||||
paths.indexTS = plugins.path.join(paths.cwd,"ts/index.ts");
|
|
||||||
paths.testTS = plugins.path.join(paths.cwd,"ts/test.ts");
|
|
||||||
|
|
||||||
plugins.gulp.task("indexTS", function(){
|
|
||||||
plugins.gulp.src(paths.indexTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "index.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd))
|
|
||||||
});
|
|
||||||
|
|
||||||
plugins.gulp.task("indexTS", function(){
|
|
||||||
plugins.gulp.src(paths.indexTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "index.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd))
|
|
||||||
});
|
|
||||||
|
|
||||||
plugins.gulp.task("testTS", function(){
|
|
||||||
plugins.gulp.src(paths.testTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "test.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd))
|
|
||||||
});
|
|
||||||
|
|
||||||
plugins.gulp.task("default",["indexTS","testTS"],function(){
|
|
||||||
plugins.beautylog.success("TypeScript for this module was compiled successfully.");
|
|
||||||
});
|
|
||||||
|
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
|
||||||
|
1
ts/npmts.cli.ts
Normal file
1
ts/npmts.cli.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
92
ts/npmts.compile.ts
Normal file
92
ts/npmts.compile.ts
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
export var run = function(configArg){
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
plugins.beautylog.log("now running custom tasks");
|
||||||
|
var moduleStream = plugins.merge2({end: false});
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- first install typings ---------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
var typingsDone = plugins.Q.defer();
|
||||||
|
var typingsCounter:number = 0;
|
||||||
|
var typingsCounterAdvance = function(){
|
||||||
|
typingsCounter++;
|
||||||
|
if(typeof config.typings[typingsCounter] != "undefined"){
|
||||||
|
installTypings();
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.success("custom typings installed successfully");
|
||||||
|
typingsDone.resolve();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var installTypings = function() {
|
||||||
|
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
|
||||||
|
plugins.typings.install({production: false, cwd: plugins.path.join(paths.cwd,config.typings[typingsCounter])})
|
||||||
|
.then(function(){
|
||||||
|
typingsCounterAdvance();
|
||||||
|
},function(){
|
||||||
|
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
|
||||||
|
typingsCounterAdvance();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
installTypings();
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- second compile TS -------------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
typingsDone.promise.then(function(){
|
||||||
|
for (var key in config.ts) {
|
||||||
|
plugins.beautylog.log("now compiling" + key.blue);
|
||||||
|
var outputPathIsDir:boolean;
|
||||||
|
try {
|
||||||
|
if(plugins.fs.statSync(plugins.path.join(paths.cwd,config.ts[key])).isDirectory()){
|
||||||
|
outputPathIsDir = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
outputPathIsDir = false;
|
||||||
|
}
|
||||||
|
//do some evaluation of the environment
|
||||||
|
var outputNameSpecified:boolean = (
|
||||||
|
!outputPathIsDir
|
||||||
|
&& (plugins.path.extname(config.ts[key]) == ".js")
|
||||||
|
);
|
||||||
|
var outputName = (function(){
|
||||||
|
if(outputNameSpecified){
|
||||||
|
return plugins.path.basename(config.ts[key])
|
||||||
|
} else {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
var outputDir = (function(){
|
||||||
|
if(outputNameSpecified){
|
||||||
|
return plugins.path.dirname(
|
||||||
|
plugins.path.join(paths.cwd,config.ts[key])
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return plugins.path.join(paths.cwd,config.ts[key])
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,key),"!**/typings/**"])
|
||||||
|
.pipe(plugins.g.sourcemaps.init()) // This means sourcemaps will be generated
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out: outputName,
|
||||||
|
target: "ES5",
|
||||||
|
module: "commonjs"
|
||||||
|
}))
|
||||||
|
.pipe(plugins.g.sourcemaps.write()) // Now the sourcemaps are added to the .js file
|
||||||
|
//.pipe(plugins.g.header('#!/usr/bin/env node\n\n'))
|
||||||
|
.pipe(plugins.gulp.dest(outputDir));
|
||||||
|
moduleStream.add(stream);
|
||||||
|
}
|
||||||
|
moduleStream.on("queueDrain",function(){
|
||||||
|
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||||
|
moduleStream.on("finish",function(){
|
||||||
|
done.resolve(config);
|
||||||
|
});
|
||||||
|
moduleStream.end();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
26
ts/npmts.configfile.ts
Normal file
26
ts/npmts.configfile.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
export var run = function(){
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config:any = {};
|
||||||
|
var configPath = plugins.path.join(paths.cwd,"npmts.json");
|
||||||
|
if(plugins.smartfile.checks.fileExistsSync(configPath)){
|
||||||
|
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
||||||
|
config = plugins.smartfile.readFileToObject(configPath);
|
||||||
|
switch (config.mode){
|
||||||
|
case "default":
|
||||||
|
case "custom":
|
||||||
|
plugins.beautylog.log("mode is " + config.mode.yellow);
|
||||||
|
done.resolve(config);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
||||||
|
config.mode = "default";
|
||||||
|
done.resolve(config);
|
||||||
|
};
|
||||||
|
return done.promise;
|
||||||
|
};
|
69
ts/npmts.jsdoc.ts
Normal file
69
ts/npmts.jsdoc.ts
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
|
||||||
|
var genJsdoc = function(){
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
plugins.beautylog.log("now generating " + "JsDoc documentation".blue);
|
||||||
|
plugins.gulp.src([
|
||||||
|
plugins.path.join(paths.cwd,"README.md"),
|
||||||
|
plugins.path.join(paths.distDir,"**/*.js")
|
||||||
|
])
|
||||||
|
.pipe(plugins.g.jsdoc3({
|
||||||
|
opts: {
|
||||||
|
destination: paths.docsDir
|
||||||
|
}
|
||||||
|
}, done.resolve));
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
var publishDocs = function(){
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
try {
|
||||||
|
var gitUrl = plugins.projectinfo.npm(
|
||||||
|
paths.cwd,
|
||||||
|
{
|
||||||
|
gitAccessToken:process.env.GITHUB_TOKEN
|
||||||
|
}
|
||||||
|
).git.httpsUrl;
|
||||||
|
|
||||||
|
var deployScript = ""
|
||||||
|
+ "cd " + paths.docsDir + " "
|
||||||
|
+ "&& git init "
|
||||||
|
+ "&& git config user.name \"TRAVIS CI\" "
|
||||||
|
+ "&& git config user.email \"travis@shipzone.io\" "
|
||||||
|
+ "&& git add . "
|
||||||
|
+ "&& git commit -m \"Deploy to GitHub Pages\" "
|
||||||
|
+ "&& git push --force --quiet "
|
||||||
|
+ "\"" + gitUrl + "\" "
|
||||||
|
+ "master:gh-pages "
|
||||||
|
+ "> /dev/null 2>&1";
|
||||||
|
}
|
||||||
|
catch (err){
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(plugins.smartenv.getEnv().isTravis){
|
||||||
|
plugins.beautylog.log("now publishing docs 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('Error: Git failed');
|
||||||
|
plugins.shelljs.exit(1);
|
||||||
|
}
|
||||||
|
done.resolve();
|
||||||
|
} else {
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export var run = function(){
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
genJsdoc()
|
||||||
|
.then(publishDocs)
|
||||||
|
.then(done.resolve);
|
||||||
|
return done.promise;
|
||||||
|
};
|
23
ts/npmts.options.ts
Normal file
23
ts/npmts.options.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
export var run = function(configArg){
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
if (typeof config.coveralls === "undefined"){
|
||||||
|
config.coveralls = false;
|
||||||
|
}
|
||||||
|
if (config.mode == "default"){
|
||||||
|
config.typings = [
|
||||||
|
"./ts/"
|
||||||
|
];
|
||||||
|
config.ts = {
|
||||||
|
["./ts/**/*.ts"]: "./dist/",
|
||||||
|
["./test/test.ts"]: "./test/"
|
||||||
|
};
|
||||||
|
config.test = ["./index.js"];
|
||||||
|
done.resolve(config);
|
||||||
|
} else {
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
};
|
16
ts/npmts.paths.ts
Normal file
16
ts/npmts.paths.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
var paths:any = {};
|
||||||
|
paths.cwd = plugins.smartcli.get.cwd().path;
|
||||||
|
|
||||||
|
//Directories
|
||||||
|
paths.tsDir = plugins.path.join(paths.cwd,"ts/");
|
||||||
|
paths.distDir = plugins.path.join(paths.cwd,"dist/");
|
||||||
|
paths.docsDir = plugins.path.join(paths.cwd,"docs/");
|
||||||
|
paths.testDir = plugins.path.join(paths.cwd,"test/");
|
||||||
|
|
||||||
|
//Files
|
||||||
|
paths.indexTS = plugins.path.join(paths.cwd,"ts/index.ts");
|
||||||
|
paths.testTS = plugins.path.join(paths.cwd,"ts/test.ts");
|
||||||
|
|
||||||
|
export = paths;
|
27
ts/npmts.plugins.ts
Normal file
27
ts/npmts.plugins.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = {
|
||||||
|
beautylog: require("beautylog"),
|
||||||
|
fs: require("fs-extra"),
|
||||||
|
gulp: require("gulp"),
|
||||||
|
g: {
|
||||||
|
coveralls: require("gulp-coveralls"),
|
||||||
|
gFunction: require("gulp-function"),
|
||||||
|
istanbul: require("gulp-istanbul"),
|
||||||
|
jsdoc3: require("gulp-jsdoc3"),
|
||||||
|
mocha: require("gulp-mocha"),
|
||||||
|
sourcemaps: require("gulp-sourcemaps"),
|
||||||
|
typescript: require("gulp-typescript")
|
||||||
|
|
||||||
|
},
|
||||||
|
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"),
|
||||||
|
typings: require("typings")
|
||||||
|
};
|
||||||
|
export = plugins;
|
15
ts/npmts.promisechain.ts
Normal file
15
ts/npmts.promisechain.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import NpmtsConfigFile = require("./npmts.configfile");
|
||||||
|
import NpmtsOptions = require("./npmts.options");
|
||||||
|
import NpmtsCompile = require("./npmts.compile");
|
||||||
|
import NpmtsJsdoc = require("./npmts.jsdoc");
|
||||||
|
import NpmtsTests = require("./npmts.tests");
|
||||||
|
export var run = function(){
|
||||||
|
var promisechain;
|
||||||
|
NpmtsConfigFile.run()
|
||||||
|
.then(NpmtsOptions.run)
|
||||||
|
.then(NpmtsCompile.run)
|
||||||
|
.then(NpmtsJsdoc.run)
|
||||||
|
.then(NpmtsTests.run);
|
||||||
|
return promisechain;
|
||||||
|
};
|
45
ts/npmts.tests.ts
Normal file
45
ts/npmts.tests.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./npmts.plugins");
|
||||||
|
import paths = require("./npmts.paths");
|
||||||
|
export var run = function(configArg) {
|
||||||
|
var done = plugins.Q.defer();
|
||||||
|
var config = configArg;
|
||||||
|
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 () {
|
||||||
|
var stream = plugins.gulp.src(["./test/test.js"])
|
||||||
|
.pipe(plugins.g.mocha())
|
||||||
|
// Creating the reports after tests ran
|
||||||
|
.pipe(plugins.g.istanbul.writeReports())
|
||||||
|
// Enforce a coverage of at least 90%
|
||||||
|
.pipe(plugins.g.istanbul.enforceThresholds({ thresholds: { global: 30 } }));
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
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());
|
||||||
|
return stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
istanbul().on("finish",function(){
|
||||||
|
mocha().on("finish",function(){
|
||||||
|
if(plugins.smartenv.getEnv().isTravis && config.coveralls){
|
||||||
|
coveralls().on("finish",function(){
|
||||||
|
done.resolve(config);
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
done.resolve(config);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
18
ts/tsd.json
18
ts/tsd.json
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "v4",
|
|
||||||
"repo": "borisyankov/DefinitelyTyped",
|
|
||||||
"ref": "master",
|
|
||||||
"path": "typings",
|
|
||||||
"bundle": "typings/tsd.d.ts",
|
|
||||||
"installed": {
|
|
||||||
"node/node.d.ts": {
|
|
||||||
"commit": "78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
|
||||||
},
|
|
||||||
"colors/colors.d.ts": {
|
|
||||||
"commit": "09e37435ffb2c56a6f908081194a74756f24f99d"
|
|
||||||
},
|
|
||||||
"vinyl/vinyl.d.ts": {
|
|
||||||
"commit": "78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
7
ts/typings.json
Normal file
7
ts/typings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||||
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
|
}
|
||||||
|
}
|
123
ts/typings/colors/colors.d.ts
vendored
123
ts/typings/colors/colors.d.ts
vendored
@ -1,123 +0,0 @@
|
|||||||
// Type definitions for Colors.js 0.6.0-1
|
|
||||||
// Project: https://github.com/Marak/colors.js
|
|
||||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
|
||||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
|
||||||
|
|
||||||
declare module "colors" {
|
|
||||||
interface Color {
|
|
||||||
(text: string): string;
|
|
||||||
|
|
||||||
black: Color;
|
|
||||||
red: Color;
|
|
||||||
green: Color;
|
|
||||||
yellow: Color;
|
|
||||||
blue: Color;
|
|
||||||
magenta: Color;
|
|
||||||
cyan: Color;
|
|
||||||
white: Color;
|
|
||||||
gray: Color;
|
|
||||||
grey: Color;
|
|
||||||
|
|
||||||
bgBlack: Color;
|
|
||||||
bgRed: Color;
|
|
||||||
bgGreen: Color;
|
|
||||||
bgYellow: Color;
|
|
||||||
bgBlue: Color;
|
|
||||||
bgMagenta: Color;
|
|
||||||
bgCyan: Color;
|
|
||||||
bgWhite: Color;
|
|
||||||
|
|
||||||
reset: Color;
|
|
||||||
bold: Color;
|
|
||||||
dim: Color;
|
|
||||||
italic: Color;
|
|
||||||
underline: Color;
|
|
||||||
inverse: Color;
|
|
||||||
hidden: Color;
|
|
||||||
strikethrough: Color;
|
|
||||||
|
|
||||||
rainbow: Color;
|
|
||||||
zebra: Color;
|
|
||||||
america: Color;
|
|
||||||
trap: Color;
|
|
||||||
random: Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
module e {
|
|
||||||
export function setTheme(theme:any): void;
|
|
||||||
|
|
||||||
export var black: Color;
|
|
||||||
export var red: Color;
|
|
||||||
export var green: Color;
|
|
||||||
export var yellow: Color;
|
|
||||||
export var blue: Color;
|
|
||||||
export var magenta: Color;
|
|
||||||
export var cyan: Color;
|
|
||||||
export var white: Color;
|
|
||||||
export var gray: Color;
|
|
||||||
export var grey: Color;
|
|
||||||
|
|
||||||
export var bgBlack: Color;
|
|
||||||
export var bgRed: Color;
|
|
||||||
export var bgGreen: Color;
|
|
||||||
export var bgYellow: Color;
|
|
||||||
export var bgBlue: Color;
|
|
||||||
export var bgMagenta: Color;
|
|
||||||
export var bgCyan: Color;
|
|
||||||
export var bgWhite: Color;
|
|
||||||
|
|
||||||
export var reset: Color;
|
|
||||||
export var bold: Color;
|
|
||||||
export var dim: Color;
|
|
||||||
export var italic: Color;
|
|
||||||
export var underline: Color;
|
|
||||||
export var inverse: Color;
|
|
||||||
export var hidden: Color;
|
|
||||||
export var strikethrough: Color;
|
|
||||||
|
|
||||||
export var rainbow: Color;
|
|
||||||
export var zebra: Color;
|
|
||||||
export var america: Color;
|
|
||||||
export var trap: Color;
|
|
||||||
export var random: Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
export = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface String {
|
|
||||||
black: string;
|
|
||||||
red: string;
|
|
||||||
green: string;
|
|
||||||
yellow: string;
|
|
||||||
blue: string;
|
|
||||||
magenta: string;
|
|
||||||
cyan: string;
|
|
||||||
white: string;
|
|
||||||
gray: string;
|
|
||||||
grey: string;
|
|
||||||
|
|
||||||
bgBlack: string;
|
|
||||||
bgRed: string;
|
|
||||||
bgGreen: string;
|
|
||||||
bgYellow: string;
|
|
||||||
bgBlue: string;
|
|
||||||
bgMagenta: string;
|
|
||||||
bgCyan: string;
|
|
||||||
bgWhite: string;
|
|
||||||
|
|
||||||
reset: string;
|
|
||||||
bold: string;
|
|
||||||
dim: string;
|
|
||||||
italic: string;
|
|
||||||
underline: string;
|
|
||||||
inverse: string;
|
|
||||||
hidden: string;
|
|
||||||
strikethrough: string;
|
|
||||||
|
|
||||||
rainbow: string;
|
|
||||||
zebra: string;
|
|
||||||
america: string;
|
|
||||||
trap: string;
|
|
||||||
random: string;
|
|
||||||
}
|
|
2090
ts/typings/node/node.d.ts
vendored
2090
ts/typings/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
3
ts/typings/tsd.d.ts
vendored
3
ts/typings/tsd.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
/// <reference path="node/node.d.ts" />
|
|
||||||
/// <reference path="colors/colors.d.ts" />
|
|
||||||
/// <reference path="vinyl/vinyl.d.ts" />
|
|
109
ts/typings/vinyl/vinyl.d.ts
vendored
109
ts/typings/vinyl/vinyl.d.ts
vendored
@ -1,109 +0,0 @@
|
|||||||
// Type definitions for vinyl 0.4.3
|
|
||||||
// Project: https://github.com/wearefractal/vinyl
|
|
||||||
// Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao>
|
|
||||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
|
||||||
|
|
||||||
/// <reference path="../node/node.d.ts" />
|
|
||||||
|
|
||||||
declare module 'vinyl' {
|
|
||||||
|
|
||||||
import fs = require('fs');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A virtual file format.
|
|
||||||
*/
|
|
||||||
class File {
|
|
||||||
constructor(options?: {
|
|
||||||
/**
|
|
||||||
* Default: process.cwd()
|
|
||||||
*/
|
|
||||||
cwd?: string;
|
|
||||||
/**
|
|
||||||
* Used for relative pathing. Typically where a glob starts.
|
|
||||||
*/
|
|
||||||
base?: string;
|
|
||||||
/**
|
|
||||||
* Full path to the file.
|
|
||||||
*/
|
|
||||||
path?: string;
|
|
||||||
/**
|
|
||||||
* Path history. Has no effect if options.path is passed.
|
|
||||||
*/
|
|
||||||
history?: string[];
|
|
||||||
/**
|
|
||||||
* The result of an fs.stat call. See fs.Stats for more information.
|
|
||||||
*/
|
|
||||||
stat?: fs.Stats;
|
|
||||||
/**
|
|
||||||
* File contents.
|
|
||||||
* Type: Buffer, Stream, or null
|
|
||||||
*/
|
|
||||||
contents?: Buffer | NodeJS.ReadWriteStream;
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default: process.cwd()
|
|
||||||
*/
|
|
||||||
public cwd: string;
|
|
||||||
/**
|
|
||||||
* Used for relative pathing. Typically where a glob starts.
|
|
||||||
*/
|
|
||||||
public base: string;
|
|
||||||
/**
|
|
||||||
* Full path to the file.
|
|
||||||
*/
|
|
||||||
public path: string;
|
|
||||||
public stat: fs.Stats;
|
|
||||||
/**
|
|
||||||
* Type: Buffer|Stream|null (Default: null)
|
|
||||||
*/
|
|
||||||
public contents: Buffer | NodeJS.ReadableStream;
|
|
||||||
/**
|
|
||||||
* Returns path.relative for the file base and file path.
|
|
||||||
* Example:
|
|
||||||
* var file = new File({
|
|
||||||
* cwd: "/",
|
|
||||||
* base: "/test/",
|
|
||||||
* path: "/test/file.js"
|
|
||||||
* });
|
|
||||||
* console.log(file.relative); // file.js
|
|
||||||
*/
|
|
||||||
public relative: string;
|
|
||||||
|
|
||||||
public isBuffer(): boolean;
|
|
||||||
|
|
||||||
public isStream(): boolean;
|
|
||||||
|
|
||||||
public isNull(): boolean;
|
|
||||||
|
|
||||||
public isDirectory(): boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.
|
|
||||||
*/
|
|
||||||
public clone(opts?: { contents?: boolean }): File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If file.contents is a Buffer, it will write it to the stream.
|
|
||||||
* If file.contents is a Stream, it will pipe it to the stream.
|
|
||||||
* If file.contents is null, it will do nothing.
|
|
||||||
*/
|
|
||||||
public pipe<T extends NodeJS.ReadWriteStream>(
|
|
||||||
stream: T,
|
|
||||||
opts?: {
|
|
||||||
/**
|
|
||||||
* If false, the destination stream will not be ended (same as node core).
|
|
||||||
*/
|
|
||||||
end?: boolean;
|
|
||||||
}
|
|
||||||
): T;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a pretty String interpretation of the File. Useful for console.log.
|
|
||||||
*/
|
|
||||||
public inspect(): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export = File;
|
|
||||||
|
|
||||||
}
|
|
Reference in New Issue
Block a user