Compare commits

...

10 Commits

Author SHA1 Message Date
1f90f4abff 5.3.22 2016-07-17 17:13:53 +02:00
3c7f5f1e2d now using npmextra 2016-07-17 17:13:47 +02:00
8104609306 5.3.21 2016-07-16 23:33:14 +02:00
a3077f7800 improve README 2016-07-16 23:33:10 +02:00
c947121243 5.3.20 2016-07-16 20:54:57 +02:00
4b3f0649fa now much faster due to skipping html coverage report 2016-07-16 20:54:52 +02:00
523c62530f 5.3.19 2016-07-16 20:14:47 +02:00
aa57617fc7 another fix 2016-07-16 20:14:43 +02:00
ef89a33dfc 5.3.18 2016-07-16 19:23:37 +02:00
474a730a09 another fix 2016-07-16 19:23:34 +02:00
10 changed files with 98 additions and 116 deletions

View File

@ -36,29 +36,28 @@ Then add it to your package.json's script section to trigger a build:
### Default task execution order ### Default task execution order
1. Check config in ./npmts.json 1. Check config in ./npmextra.json (Check out [npmextra](https://www.npmjs.com/package/npmextra))
1. Clean up from any previous builds (old js files) 1. Clean up from any previous builds (old js files)
1. Install typings 1. Transpile TypeScript with **inline sourcemaps** and **declaration files** to ES6
1. Transpile TypeScript with **inline sourcemaps** and **declaration files** 1. Create TypeDoc Documentation from TypeScript files
1. Create EsDoc Documentation 1. Instrumentalize transpiled ES6 JavaScript with istanbul and run tests with Mocha
1. Instrumentalize created JavaScript files with istanbul
1. Run Tests
1. Create Coverage report
#### npmts.json #### npmtsextra.json
the npmts.json is the main config file. You can use it to customize the behaviour of NPMTS. the npmts section in npmtsextra.json can be used to configure npmts.
```json ```json
{ {
"mode":"default", "npmts":{
"ts":{ "mode":"default",
"./customdir/*.ts":"./" "ts":{
}, "./customdir/*.ts":"./"
"tsOptions":{ },
"declaration":false, "tsOptions":{
"target":"ES6" "declaration":false,
}, "target":"ES6"
"cli":true },
"cli":true
}
} }
``` ```
@ -111,7 +110,7 @@ thanks to autogenerated source maps.
## Tips and tricks: ## Tips and tricks:
* Use [npmts-g](https://www.npmjs.com/package/npmts-g) to use globally installed npmts and install npmts locally if no global npmts is available. * Use [npmts-g](https://www.npmjs.com/package/npmts-g) to use globally installed npmts and install npmts locally if no global npmts is available.
* Use [npmpage](https://www.npmjs.com/package/npmtspage) to create a webpage from coverage reports and EsDocs for the module * Use [npmpage](https://www.npmjs.com/package/npmtspage) to create a webpage from coverage reports and TypeDoc for the module
* Use [hosttoday/ht-docker-node:npmts](https://hub.docker.com/r/hosttoday/ht-docker-node/) for speedy CI builds * Use [hosttoday/ht-docker-node:npmts](https://hub.docker.com/r/hosttoday/ht-docker-node/) for speedy CI builds
## About the authors: ## About the authors:

View File

@ -2,33 +2,34 @@
require("typings-global"); require("typings-global");
var plugins = require("./npmts.plugins"); var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths"); var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
exports.run = function (argvArg) { exports.run = function (argvArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
var config = {}; npmts_promisechain_1.npmtsOra.text("looking for npmextra.json");
var configPath = plugins.path.join(paths.cwd, "npmts.json"); var defaultConfig = {
mode: "default",
notest: false
};
if (argvArg.notest) { if (argvArg.notest) {
config.notest = true; defaultConfig.notest = true;
}
if (plugins.smartfile.fs.fileExistsSync(configPath)) {
plugins.beautylog.info("npmts.json".blue + " config file found!");
config = plugins.lodashObject.assign(config, plugins.smartfile.fs.toObjectSync(configPath));
switch (config.mode) {
case "default":
case "custom":
plugins.beautylog.ok("mode is " + config.mode.yellow);
done.resolve(config);
break;
default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
}
;
}
else {
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
config.mode = "default";
done.resolve(config);
} }
; ;
var config = plugins.npmextra.dataFor({
toolName: "npmts",
defaultSettings: defaultConfig,
cwd: paths.cwd
});
switch (config.mode) {
case "default":
case "custom":
plugins.beautylog.ok("mode is " + config.mode.yellow);
done.resolve(config);
break;
default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
}
;
done.resolve(config);
return done.promise; return done.promise;
}; };

View File

@ -11,9 +11,8 @@ export declare let g: {
sourcemaps: any; sourcemaps: any;
typedoc: any; typedoc: any;
}; };
import "babel-preset-es2015";
export declare let lodashObject: any; export declare let lodashObject: any;
export declare let merge2: any; export import npmextra = require("npmextra");
export import projectinfo = require("projectinfo"); export import projectinfo = require("projectinfo");
export import path = require("path"); export import path = require("path");
export import Q = require("q"); export import Q = require("q");

View File

@ -12,9 +12,8 @@ exports.g = {
sourcemaps: require("gulp-sourcemaps"), sourcemaps: require("gulp-sourcemaps"),
typedoc: require("gulp-typedoc") typedoc: require("gulp-typedoc")
}; };
require("babel-preset-es2015");
exports.lodashObject = require('lodash/fp/object'); exports.lodashObject = require('lodash/fp/object');
exports.merge2 = require("merge2"); exports.npmextra = require("npmextra");
exports.projectinfo = require("projectinfo"); exports.projectinfo = require("projectinfo");
exports.path = require("path"); exports.path = require("path");
exports.Q = require("q"); exports.Q = require("q");

15
dist/npmts.tests.js vendored
View File

@ -14,19 +14,26 @@ var mocha = function (configArg) {
var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")]) var stream = plugins.gulp.src([plugins.path.join(paths.cwd, "dist/*.js")])
.pipe(plugins.g.sourcemaps.init()) .pipe(plugins.g.sourcemaps.init())
.pipe(plugins.g.babel({ .pipe(plugins.g.babel({
presets: ['es2015'] presets: [
require.resolve("babel-preset-es2015")
]
})) }))
.pipe(plugins.g.istanbul()) .pipe(plugins.g.istanbul({}))
.pipe(plugins.g.sourcemaps.write()) .pipe(plugins.g.sourcemaps.write())
.pipe(plugins.g.injectModules()) .pipe(plugins.g.injectModules())
.on("finish", function () { .on("finish", function () {
plugins.gulp.src([plugins.path.join(paths.cwd, "test/test.js")]) plugins.gulp.src([plugins.path.join(paths.cwd, "test/test.js")])
.pipe(plugins.g.babel({ .pipe(plugins.g.babel({
presets: ['es2015'] presets: [
plugins.path.join(paths.npmtsPackageRoot, "node_modules/babel-preset-es2015/index.js")
]
})) }))
.pipe(plugins.g.injectModules()) .pipe(plugins.g.injectModules())
.pipe(plugins.g.mocha()) .pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports()) .pipe(plugins.g.istanbul.writeReports({
dir: './coverage',
reporters: ['lcovonly', 'json', 'text', 'text-summary']
}))
.pipe(plugins.g.gFunction(function () { .pipe(plugins.g.gFunction(function () {
plugins.beautylog.ok("Tested!"); plugins.beautylog.ok("Tested!");
done.resolve(configArg); done.resolve(configArg);

View File

@ -1,30 +0,0 @@
0 info it worked if it ends with ok
1 verbose cli [ '/Users/philkunz/.nvm/versions/node/v4.4.5/bin/node',
1 verbose cli '/Users/philkunz/.nvm/versions/node/v4.4.5/bin/npm',
1 verbose cli 'version',
1 verbose cli 'patch' ]
2 info using npm@3.10.3
3 info using node@v4.4.5
4 info git [ 'status', '--porcelain' ]
5 verbose stack Error: Git working directory not clean.
5 verbose stack M package.json
5 verbose stack at /Users/philkunz/.nvm/versions/node/v4.4.5/lib/node_modules/npm/lib/version.js:247:19
5 verbose stack at /Users/philkunz/.nvm/versions/node/v4.4.5/lib/node_modules/npm/lib/utils/no-progress-while-running.js:21:8
5 verbose stack at ChildProcess.exithandler (child_process.js:204:7)
5 verbose stack at emitTwo (events.js:87:13)
5 verbose stack at ChildProcess.emit (events.js:172:7)
5 verbose stack at maybeClose (internal/child_process.js:827:16)
5 verbose stack at Socket.<anonymous> (internal/child_process.js:319:11)
5 verbose stack at emitOne (events.js:77:13)
5 verbose stack at Socket.emit (events.js:169:7)
5 verbose stack at Pipe._onclose (net.js:477:12)
6 verbose cwd /Users/philkunz/gitlab/pushrocks/npmts
7 error Darwin 15.5.0
8 error argv "/Users/philkunz/.nvm/versions/node/v4.4.5/bin/node" "/Users/philkunz/.nvm/versions/node/v4.4.5/bin/npm" "version" "patch"
9 error node v4.4.5
10 error npm v3.10.3
11 error Git working directory not clean.
11 error M package.json
12 error If you need help, you may report this error at:
12 error <https://github.com/npm/npm/issues>
13 verbose exit [ 1, true ]

View File

@ -1,6 +1,6 @@
{ {
"name": "npmts", "name": "npmts",
"version": "5.3.17", "version": "5.3.22",
"description": "write npm modules with TypeScript", "description": "write npm modules with TypeScript",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {
@ -29,9 +29,9 @@
}, },
"homepage": "https://gitlab.com/pushrocks/npmts#readme", "homepage": "https://gitlab.com/pushrocks/npmts#readme",
"dependencies": { "dependencies": {
"@types/minimatch": "*", "@types/minimatch": "^2.0.28",
"@types/q": "*", "@types/q": "^0.0.27",
"@types/shelljs": "*", "@types/shelljs": "^0.3.27",
"babel-preset-es2015": "^6.9.0", "babel-preset-es2015": "^6.9.0",
"beautylog": "5.0.14", "beautylog": "5.0.14",
"early": "^2.0.13", "early": "^2.0.13",
@ -47,6 +47,7 @@
"gulp-sourcemaps": "^1.6.0", "gulp-sourcemaps": "^1.6.0",
"gulp-typedoc": "^2.0.0", "gulp-typedoc": "^2.0.0",
"lodash": "^4.13.1", "lodash": "^4.13.1",
"npmextra": "^1.0.7",
"projectinfo": "1.0.3", "projectinfo": "1.0.3",
"q": "^1.4.1", "q": "^1.4.1",
"shelljs": "^0.7.0", "shelljs": "^0.7.0",

View File

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

View File

@ -11,9 +11,8 @@ export let g = {
sourcemaps: require("gulp-sourcemaps"), sourcemaps: require("gulp-sourcemaps"),
typedoc: require("gulp-typedoc") typedoc: require("gulp-typedoc")
}; };
import "babel-preset-es2015";
export let lodashObject = require('lodash/fp/object'); export let lodashObject = require('lodash/fp/object');
export let merge2 = require("merge2"); export import npmextra = require("npmextra");
export import projectinfo = require("projectinfo"); export import projectinfo = require("projectinfo");
export import path = require("path"); export import path = require("path");
export import Q = require("q"); export import Q = require("q");

View File

@ -14,19 +14,27 @@ let mocha = function (configArg) {
var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")]) var stream = plugins.gulp.src([plugins.path.join(paths.cwd,"dist/*.js")])
.pipe(plugins.g.sourcemaps.init()) .pipe(plugins.g.sourcemaps.init())
.pipe(plugins.g.babel({ .pipe(plugins.g.babel({
presets: ['es2015'] presets: [
require.resolve("babel-preset-es2015")
]
}))
.pipe(plugins.g.istanbul({
})) }))
.pipe(plugins.g.istanbul())
.pipe(plugins.g.sourcemaps.write()) .pipe(plugins.g.sourcemaps.write())
.pipe(plugins.g.injectModules()) .pipe(plugins.g.injectModules())
.on("finish",function(){ .on("finish",function(){
plugins.gulp.src([plugins.path.join(paths.cwd,"test/test.js")]) plugins.gulp.src([plugins.path.join(paths.cwd,"test/test.js")])
.pipe(plugins.g.babel({ .pipe(plugins.g.babel({
presets: ['es2015'] presets: [
plugins.path.join(paths.npmtsPackageRoot,"node_modules/babel-preset-es2015/index.js")
]
})) }))
.pipe(plugins.g.injectModules()) .pipe(plugins.g.injectModules())
.pipe(plugins.g.mocha()) .pipe(plugins.g.mocha())
.pipe(plugins.g.istanbul.writeReports()) .pipe(plugins.g.istanbul.writeReports({
dir: './coverage',
reporters: [ 'lcovonly', 'json', 'text', 'text-summary']
}))
.pipe(plugins.g.gFunction(function(){ .pipe(plugins.g.gFunction(function(){
plugins.beautylog.ok("Tested!"); plugins.beautylog.ok("Tested!");
done.resolve(configArg); done.resolve(configArg);