update options

This commit is contained in:
Philipp Kunz 2016-08-19 09:46:36 +02:00
parent 51753df662
commit 2edcb3947e
15 changed files with 152 additions and 140 deletions

View File

@ -46,10 +46,25 @@ Then add it to your package.json's script section to trigger a build:
### npmextra.json ### npmextra.json
the npmts section in npmextra.json can be used to configure npmts. the npmts section in npmextra.json can be used to configure npmts.
**Default**
>Note: When you are using `"mode":"default"` it'll cause npmts to override any other settings you may have made except for tsOptions (ES target etc.)
with default behaviour.
```json ```json
{ {
"npmts":{ "npmts":{
"mode":"default", "mode":"default"
}
}
```
**Custom settings**
```json
{
"mode":"custom",
"docs":false,
"test":true,
"npmts":{
"ts":{ "ts":{
"./customdir/*.ts":"./" "./customdir/*.ts":"./"
}, },
@ -64,7 +79,9 @@ the npmts section in npmextra.json can be used to configure npmts.
| key | default value | description | | key | default value | description |
| --- | --- | --- | | --- | --- | --- |
| `"mode"` | `"default"` | "default" will do some default stuff, "custom" only does what you specify | | `"mode"` | `"default"` | "default" will do default stuff and override , "custom" only does what you specify |
| `"docs"` | `true` | create docs for your module |
| `"test"` | `true` | test your module |
| `"ts"` | `{"./ts/*.ts":"./","./test/test.ts":"./test/"}` | allows you to define multiple ts portions | | `"ts"` | `{"./ts/*.ts":"./","./test/test.ts":"./test/"}` | allows you to define multiple ts portions |
| `"tsOptions"` | `{"target":"ES5", "declaration":"true"}` | specify options for tsc | | `"tsOptions"` | `{"target":"ES5", "declaration":"true"}` | specify options for tsc |
| `"cli"` | "false" | some modules are designed to be used from cli. If set to true NPMTS will create a cli.js that wires you dist files up for cli use. | | `"cli"` | "false" | some modules are designed to be used from cli. If set to true NPMTS will create a cli.js that wires you dist files up for cli use. |

2
dist/cli.js vendored
View File

@ -1,2 +0,0 @@
#!/usr/bin/env node
var index = require("./index.js");

View File

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

View File

@ -1,40 +0,0 @@
"use strict";
require("typings-global");
var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain");
exports.run = function (argvArg) {
var done = plugins.Q.defer();
npmts_promisechain_1.npmtsOra.text("looking for npmextra.json");
var defaultConfig = {
mode: "default",
notest: false,
nodocs: false
};
if (argvArg.notest) {
defaultConfig.notest = true;
}
;
if (argvArg.nodocs) {
defaultConfig.nodocs = true;
}
;
var config = plugins.npmextra.dataFor({
toolName: "npmts",
defaultSettings: defaultConfig,
cwd: paths.cwd
});
switch (config.mode) {
case "default":
case "custom":
plugins.beautylog.ok("mode is " + config.mode.yellow);
done.resolve(config);
break;
default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
}
;
done.resolve(config);
return done.promise;
};

View File

@ -1,4 +1,15 @@
/// <reference types="q" /> /// <reference types="q" />
import "typings-global"; import "typings-global";
import plugins = require("./npmts.plugins"); import plugins = require("./npmts.plugins");
export declare var run: (configArg: any) => plugins.Q.Promise<{}>; export declare type npmtsMode = "default" | "custom";
export interface npmtsConfig {
argv: any;
coverageTreshold: number;
docs: boolean;
mode: npmtsMode;
test: boolean;
testTs: any;
ts: any;
tsOptions: any;
}
export declare var run: (argvArg: any) => plugins.Q.Promise<{}>;

54
dist/npmts.options.js vendored
View File

@ -1,16 +1,42 @@
"use strict"; "use strict";
require("typings-global"); require("typings-global");
var plugins = require("./npmts.plugins"); var plugins = require("./npmts.plugins");
var paths = require("./npmts.paths");
var npmts_promisechain_1 = require("./npmts.promisechain"); var npmts_promisechain_1 = require("./npmts.promisechain");
exports.run = function (configArg) { ;
exports.run = function (argvArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
var config = configArg; var defaultConfig = {
npmts_promisechain_1.npmtsOra.text("now determining build options..."); argv: undefined,
coverageTreshold: 70,
docs: true,
mode: "default",
test: true,
testTs: {},
ts: {},
tsOptions: {}
};
// mix with configfile
npmts_promisechain_1.npmtsOra.text("looking for npmextra.json");
var config = plugins.npmextra.dataFor({
toolName: "npmts",
defaultSettings: defaultConfig,
cwd: paths.cwd
});
// check mode
switch (config.mode) {
case "default":
case "custom":
plugins.beautylog.ok("mode is " + config.mode);
done.resolve(config);
break;
default:
plugins.beautylog.error("mode " + config.mode + " not recognised!".red);
process.exit(1);
}
;
//handle default mode //handle default mode
if (config.mode == "default") { if (config.mode == "default") {
config.typings = [
"./ts/typings.json"
];
config.ts = (_a = {}, config.ts = (_a = {},
_a["./ts/**/*.ts"] = "./dist/", _a["./ts/**/*.ts"] = "./dist/",
_a _a
@ -19,13 +45,17 @@ exports.run = function (configArg) {
_b["./test/test.ts"] = "./test/", _b["./test/test.ts"] = "./test/",
_b _b
); );
config.test = ["./index.js"];
} }
//check if config.tsOptions is available ;
config.tsOptions ? void (0) : config.tsOptions = {}; // mix with commandline
config.coverageTreshold ? void (0) : config.coverageTreshold = 70; if (config.argv.notest) {
// handle docs config.test = false;
config.docs ? void (0) : config.docs = {}; }
;
if (config.argv.nodocs) {
config.docs = false;
}
;
plugins.beautylog.ok("build options are ready!"); plugins.beautylog.ok("build options are ready!");
done.resolve(config); done.resolve(config);
return done.promise; return done.promise;

View File

@ -6,15 +6,13 @@ var NpmtsAssets = require("./npmts.assets");
var NpmtsCheck = require("./npmts.check"); var NpmtsCheck = require("./npmts.check");
var NpmtsClean = require("./npmts.clean"); var NpmtsClean = require("./npmts.clean");
var NpmtsCompile = require("./npmts.compile"); var NpmtsCompile = require("./npmts.compile");
var NpmtsConfigFile = require("./npmts.configfile");
var NpmtsTypeDoc = require("./npmts.typedoc"); var NpmtsTypeDoc = require("./npmts.typedoc");
var NpmtsOptions = require("./npmts.options"); var NpmtsOptions = require("./npmts.options");
var NpmtsTests = require("./npmts.tests"); var NpmtsTests = require("./npmts.tests");
exports.promisechain = function (argvArg) { exports.promisechain = function (argvArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
exports.npmtsOra.start(); exports.npmtsOra.start();
NpmtsConfigFile.run(argvArg) NpmtsOptions.run(argvArg)
.then(NpmtsOptions.run)
.then(NpmtsClean.run) .then(NpmtsClean.run)
.then(NpmtsCheck.run) .then(NpmtsCheck.run)
.then(NpmtsCompile.run) .then(NpmtsCompile.run)

2
dist/npmts.tests.js vendored
View File

@ -60,7 +60,7 @@ var coverage = function (configArg) {
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 (config.notest != true) { if (config.test === true) {
npmts_promisechain_1.npmtsOra.text("now starting tests"); npmts_promisechain_1.npmtsOra.text("now starting tests");
plugins.beautylog.log("-------------------------------------------------------\n" + plugins.beautylog.log("-------------------------------------------------------\n" +
"*************************** TESTS: ***************************\n" + "*************************** TESTS: ***************************\n" +

View File

@ -27,15 +27,15 @@ var genTypeDoc = function (configArg) {
}; };
exports.run = function (configArg) { exports.run = function (configArg) {
var done = plugins.Q.defer(); var done = plugins.Q.defer();
if (configArg.nodocs) { if (configArg.docs) {
done.resolve(configArg);
}
else {
genTypeDoc(configArg) genTypeDoc(configArg)
.then(function () { .then(function () {
done.resolve(configArg); done.resolve(configArg);
}); });
} }
else {
done.resolve(configArg);
}
; ;
return done.promise; return done.promise;
}; };

View File

@ -30,23 +30,23 @@
}, },
"homepage": "https://gitlab.com/pushrocks/npmts#readme", "homepage": "https://gitlab.com/pushrocks/npmts#readme",
"dependencies": { "dependencies": {
"@types/gulp": "^3.8.28", "@types/gulp": "^3.8.29",
"@types/minimatch": "^2.0.28", "@types/minimatch": "^2.0.28",
"@types/q": "^0.0.27", "@types/q": "^0.x.x",
"@types/shelljs": "^0.3.27", "@types/shelljs": "^0.3.28",
"babel-preset-es2015": "^6.9.0", "babel-preset-es2015": "^6.13.2",
"beautylog": "5.0.18", "beautylog": "5.0.20",
"depcheck": "^0.6.4", "depcheck": "^0.6.4",
"early": "^2.0.13", "early": "^2.0.13",
"gulp": "3.9.1", "gulp": "3.9.1",
"gulp-babel": "^6.1.2", "gulp-babel": "^6.1.2",
"gulp-function": "^1.3.6", "gulp-function": "^1.3.6",
"gulp-inject-modules": "^1.0.0", "gulp-inject-modules": "^1.0.0",
"gulp-istanbul": "^1.0.0", "gulp-istanbul": "^1.1.0",
"gulp-mocha": "^2.2.0", "gulp-mocha": "^3.0.1",
"gulp-sourcemaps": "^1.6.0", "gulp-sourcemaps": "^1.6.0",
"gulp-typedoc": "^2.0.0", "gulp-typedoc": "^2.0.0",
"lodash": "^4.14.0", "lodash": "^4.15.0",
"npmextra": "^1.0.8", "npmextra": "^1.0.8",
"projectinfo": "1.0.3", "projectinfo": "1.0.3",
"q": "^1.4.1", "q": "^1.4.1",
@ -54,12 +54,12 @@
"smartcli": "1.0.4", "smartcli": "1.0.4",
"smartcov": "0.0.9", "smartcov": "0.0.9",
"smartenv": "1.2.5", "smartenv": "1.2.5",
"smartfile": "4.0.12", "smartfile": "4.0.13",
"smartpath": "3.2.2", "smartpath": "3.2.2",
"smartstring": "^2.0.15", "smartstring": "^2.0.17",
"source-map-support": "^0.4.2", "source-map-support": "^0.4.2",
"tsn": "^1.0.10", "tsn": "^1.0.12",
"typedoc": "^0.4.4", "typedoc": "^0.4.5",
"typescript": "^2.0.0-dev.20160630", "typescript": "^2.0.0-dev.20160630",
"typings-global": "*" "typings-global": "*"
}, },

View File

@ -1,36 +0,0 @@
import "typings-global";
import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
import {npmtsOra} from "./npmts.promisechain";
export var run = function(argvArg){
let done = plugins.Q.defer();
npmtsOra.text("looking for npmextra.json");
let defaultConfig = {
mode: "default",
notest:false,
nodocs:false
};
if(argvArg.notest){
defaultConfig.notest = true;
};
if(argvArg.nodocs){
defaultConfig.nodocs = true;
};
let config = plugins.npmextra.dataFor({
toolName:"npmts",
defaultSettings:defaultConfig,
cwd:paths.cwd
});
switch (config.mode){
case "default":
case "custom":
plugins.beautylog.ok("mode is " + config.mode.yellow);
done.resolve(config);
break;
default:
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
process.exit(1);
};
done.resolve(config);
return done.promise;
};

View File

@ -1,36 +1,76 @@
import "typings-global"; import "typings-global";
import plugins = require("./npmts.plugins"); import plugins = require("./npmts.plugins");
import paths = require("./npmts.paths");
import {npmtsOra} from "./npmts.promisechain"; import {npmtsOra} from "./npmts.promisechain";
export var run = function(configArg){ export type npmtsMode = "default" | "custom"
var done = plugins.Q.defer();
var config = configArg;
npmtsOra.text("now determining build options..."); export interface npmtsConfig {
argv:any,
coverageTreshold:number,
docs:boolean,
mode: npmtsMode,
test:boolean,
testTs:any,
ts:any,
tsOptions:any
};
export var run = function(argvArg){
let done = plugins.Q.defer();
let defaultConfig:npmtsConfig = {
argv:undefined,
coverageTreshold: 70,
docs: true,
mode:"default",
test:true,
testTs:{},
ts:{},
tsOptions: {}
};
// mix with configfile
npmtsOra.text("looking for npmextra.json");
let config:npmtsConfig = plugins.npmextra.dataFor({
toolName:"npmts",
defaultSettings:defaultConfig,
cwd:paths.cwd
});
// check mode
switch (config.mode){
case "default":
case "custom":
plugins.beautylog.ok("mode is " + config.mode);
done.resolve(config);
break;
default:
plugins.beautylog.error("mode " + config.mode + " not recognised!".red);
process.exit(1);
};
//handle default mode //handle default mode
if (config.mode == "default"){ if (config.mode == "default"){
config.typings = [
"./ts/typings.json"
];
config.ts = { config.ts = {
["./ts/**/*.ts"]: "./dist/" ["./ts/**/*.ts"]: "./dist/"
}; };
config.testTs = { config.testTs = {
["./test/test.ts"]: "./test/" ["./test/test.ts"]: "./test/"
}; };
config.test = ["./index.js"]; };
}
//check if config.tsOptions is available
config.tsOptions ? void(0) : config.tsOptions = {};
config.coverageTreshold ? void(0) : config.coverageTreshold = 70; // mix with commandline
if(config.argv.notest){
config.test = false;
};
if(config.argv.nodocs){
config.docs = false;
};
// handle docs
config.docs ? void(0) : config.docs = {};
plugins.beautylog.ok("build options are ready!"); plugins.beautylog.ok("build options are ready!");
done.resolve(config); done.resolve(config);

View File

@ -8,7 +8,6 @@ import NpmtsAssets = require("./npmts.assets");
import NpmtsCheck = require("./npmts.check"); import NpmtsCheck = require("./npmts.check");
import NpmtsClean = require("./npmts.clean"); import NpmtsClean = require("./npmts.clean");
import NpmtsCompile = require("./npmts.compile"); import NpmtsCompile = require("./npmts.compile");
import NpmtsConfigFile = require("./npmts.configfile");
import NpmtsTypeDoc = require("./npmts.typedoc"); import NpmtsTypeDoc = require("./npmts.typedoc");
import NpmtsOptions = require("./npmts.options"); import NpmtsOptions = require("./npmts.options");
import NpmtsTests = require("./npmts.tests"); import NpmtsTests = require("./npmts.tests");
@ -16,8 +15,7 @@ import NpmtsTests = require("./npmts.tests");
export let promisechain = function(argvArg){ export let promisechain = function(argvArg){
let done = plugins.Q.defer(); let done = plugins.Q.defer();
npmtsOra.start(); npmtsOra.start();
NpmtsConfigFile.run(argvArg) NpmtsOptions.run(argvArg)
.then(NpmtsOptions.run)
.then(NpmtsClean.run) .then(NpmtsClean.run)
.then(NpmtsCheck.run) .then(NpmtsCheck.run)
.then(NpmtsCompile.run) .then(NpmtsCompile.run)

View File

@ -66,7 +66,7 @@ let coverage = function(configArg){
export let run = function(configArg) { export let run = function(configArg) {
let done = plugins.Q.defer(); let done = plugins.Q.defer();
let config = configArg; let config = configArg;
if(config.notest != true){ if(config.test === true){
npmtsOra.text("now starting tests"); npmtsOra.text("now starting tests");
plugins.beautylog.log( plugins.beautylog.log(
"-------------------------------------------------------\n" + "-------------------------------------------------------\n" +

View File

@ -32,13 +32,13 @@ let genTypeDoc = function (configArg) {
export let run = function (configArg) { export let run = function (configArg) {
let done = plugins.Q.defer(); let done = plugins.Q.defer();
if (configArg.nodocs) { if (configArg.docs) {
done.resolve(configArg);
} else {
genTypeDoc(configArg) genTypeDoc(configArg)
.then(() => { .then(() => {
done.resolve(configArg); done.resolve(configArg);
}); });
} else {
done.resolve(configArg);
}; };
return done.promise; return done.promise;
}; };