Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
372d2605bb | |||
2ecf6c00b8 | |||
2f3d8cecd3 | |||
54bbab232e | |||
380407b5e8 | |||
2a5583946c | |||
80e36a34ee | |||
1f90f4abff | |||
3c7f5f1e2d |
32
README.md
32
README.md
@ -1,5 +1,5 @@
|
|||||||
# npmts
|
# npmts
|
||||||
Write npm modules with TypeScript without hassle.
|
Write npm modules with TypeScript without hassle. TypeScript ready. Fully ES6.
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
[](https://gitlab.com/pushrocks/npmts/commits/master)
|
[](https://gitlab.com/pushrocks/npmts/commits/master)
|
||||||
@ -36,13 +36,13 @@ 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 ./npmextra.json (Check out [npmextra](https://www.npmjs.com/package/npmextra))
|
1. **Config:** 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:** Clean up from any previous builds (old js files)
|
||||||
1. Transpile TypeScript with **inline sourcemaps** and **declaration files** to ES6
|
1. **Transpile:** Transpile TypeScript with **inline sourcemaps** and **declaration files** to ES6
|
||||||
1. Create TypeDoc Documentation from TypeScript files
|
1. **Documentation:** Create TypeDoc Documentation from TypeScript files
|
||||||
1. Instrumentalize transpiled ES6 JavaScript with istanbul and run tests with Mocha
|
1. **Test:** Babelify ES6 to ES5 on the fly, instrumentalize ES5 JavaScript with istanbul and run tests with Mocha.
|
||||||
|
|
||||||
#### npmtsextra.json
|
### npmextra.json
|
||||||
the npmts section in npmtsextra.json can be used to configure npmts.
|
the npmts section in npmtsextra.json can be used to configure npmts.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
@ -63,20 +63,17 @@ the npmts section in npmtsextra.json can be used to configure npmts.
|
|||||||
|
|
||||||
| key | default value | description |
|
| key | default value | description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `"codecov"` | `true` | if true, coverage data will be uploaded to codecov when running on travis |
|
| `"mode"` | `"default"` | "default" will do some default stuff, "custom" only does what you specify |
|
||||||
| `"docs"` | `{"publish":"false"}` | `{"publish":true, destination:"github"}` lets you control what happens with your module documentation |
|
|
||||||
| `"mode"` | `"default"` | "default" will do some defualt stuff, "custom" only does what you specify |
|
|
||||||
| `"tsOptions"` | `{"target":"ES5", "declaration":"true"}` | specify options for tsc |
|
| `"tsOptions"` | `{"target":"ES5", "declaration":"true"}` | specify options for tsc |
|
||||||
| `"typings"` | `["./ts/typings.json"]` | allows you to specify multiple locations for typings.json to install. This is needed for modules that do not yet bundle typings |
|
|
||||||
| `"cli"` | "false" | some modules are designed to be used from cli. If set to true NPMTS will create a cli.js that wires you dist files up for cli use. |
|
| `"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. |
|
||||||
|
|
||||||
#### TypeScript
|
### TypeScript
|
||||||
by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
|
by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
|
||||||
`./dist/*.js` and `./test/test.js`
|
`./dist/*.js` and `./test/test.js`
|
||||||
|
|
||||||
Use commonjs module system for wiring up files.
|
Use commonjs module system for wiring up files.
|
||||||
|
|
||||||
#### Declaration files
|
### Declaration files
|
||||||
**npmts** also creates an `./dist/index.d.ts` declaration file by default.
|
**npmts** also creates an `./dist/index.d.ts` declaration file by default.
|
||||||
You can reference it in your package.json like this.
|
You can reference it in your package.json like this.
|
||||||
|
|
||||||
@ -89,6 +86,7 @@ This is in line with the latest TypeScript best practices.
|
|||||||
You can then import plugins via the TypeScript `import` Syntax
|
You can then import plugins via the TypeScript `import` Syntax
|
||||||
and tsc will pick up the declaration file automatically.
|
and tsc will pick up the declaration file automatically.
|
||||||
|
|
||||||
|
## Some notes:
|
||||||
#### Typings for third party modules that do not bundle declaration files
|
#### Typings for third party modules that do not bundle declaration files
|
||||||
NPMTS does no longer supports typings.json. Instead use the new TypeScript 2.x approach to typings using the @types/ npm scope.
|
NPMTS does no longer supports typings.json. Instead use the new TypeScript 2.x approach to typings using the @types/ npm scope.
|
||||||
|
|
||||||
@ -96,22 +94,20 @@ NPMTS does no longer supports typings.json. Instead use the new TypeScript 2.x a
|
|||||||
npmts instrumentalizes (using istanbul) the created JavaScript code to create a coverage report.
|
npmts instrumentalizes (using istanbul) the created JavaScript code to create a coverage report.
|
||||||
|
|
||||||
#### Tests
|
#### Tests
|
||||||
When Typings have been installed, TypeScript + Declaration files have been transpiled and the resulting JS has been instrumentalized,
|
|
||||||
npmts looks for `.test/test.ts` which will be transpiled to test.js and run with mocha.
|
|
||||||
|
|
||||||
Any errors will be shown with reference to their originating source in TypeScript
|
Any errors will be shown with reference to their originating source in TypeScript
|
||||||
thanks to autogenerated source maps.
|
thanks to autogenerated source maps.
|
||||||
|
|
||||||
## Example Usage in modules:
|
## Example Usage in modules:
|
||||||
* [gulp-browser](https://www.npmjs.com/package/gulp-typings)
|
* [gulp-browser](https://www.npmjs.com/package/gulp-browser)
|
||||||
|
|
||||||
> We will add more options over time.
|
> We will add more options over time.
|
||||||
|
|
||||||
## 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 TypeDoc for the module
|
* Use [npmpage](https://www.npmjs.com/package/npmpage) to create a webpage from coverage reports and TypeDoc for the module
|
||||||
* Use [hosttoday/ht-docker-node:npmts](https://hub.docker.com/r/hosttoday/ht-docker-node/) for speedy CI builds
|
* Use [hosttoday/ht-docker-node:npmts](https://hub.docker.com/r/hosttoday/ht-docker-node/) for speedy CI builds
|
||||||
|
* Use [npmdocker](https://www.npmjs.com/package/npmdocker) for running tests consistently with docker.
|
||||||
|
|
||||||
## About the authors:
|
## About the authors:
|
||||||
[](https://lossless.com/)
|
[](https://lossless.com/)
|
||||||
|
3
dist/npmts.assets.js
vendored
3
dist/npmts.assets.js
vendored
@ -8,11 +8,12 @@ exports.run = function (configArg) {
|
|||||||
var config = configArg;
|
var config = configArg;
|
||||||
npmts_promisechain_1.npmtsOra.text("now looking at " + "required assets".yellow);
|
npmts_promisechain_1.npmtsOra.text("now looking at " + "required assets".yellow);
|
||||||
if (config.cli == true) {
|
if (config.cli == true) {
|
||||||
plugins.smartfile.fs.copy(plugins.path.join(paths.npmtsAssetsDir, "cli.js"), paths.distDir);
|
plugins.smartfile.fs.copySync(plugins.path.join(paths.npmtsAssetsDir, "cli.js"), plugins.path.join(paths.distDir, "cli.js"));
|
||||||
plugins.beautylog.ok("installed CLI assets!");
|
plugins.beautylog.ok("installed CLI assets!");
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
plugins.beautylog.ok("No additional assets required!");
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
}
|
}
|
||||||
return done.promise;
|
return done.promise;
|
||||||
|
25
dist/npmts.configfile.js
vendored
25
dist/npmts.configfile.js
vendored
@ -2,16 +2,23 @@
|
|||||||
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!");
|
var config = plugins.npmextra.dataFor({
|
||||||
config = plugins.lodashObject.assign(config, plugins.smartfile.fs.toObjectSync(configPath));
|
toolName: "npmts",
|
||||||
|
defaultSettings: defaultConfig,
|
||||||
|
cwd: paths.cwd
|
||||||
|
});
|
||||||
switch (config.mode) {
|
switch (config.mode) {
|
||||||
case "default":
|
case "default":
|
||||||
case "custom":
|
case "custom":
|
||||||
@ -23,12 +30,6 @@ exports.run = function (argvArg) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
|
||||||
config.mode = "default";
|
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
}
|
|
||||||
;
|
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
1
dist/npmts.plugins.d.ts
vendored
1
dist/npmts.plugins.d.ts
vendored
@ -12,6 +12,7 @@ export declare let g: {
|
|||||||
typedoc: any;
|
typedoc: any;
|
||||||
};
|
};
|
||||||
export declare let lodashObject: any;
|
export declare let lodashObject: 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");
|
||||||
|
1
dist/npmts.plugins.js
vendored
1
dist/npmts.plugins.js
vendored
@ -13,6 +13,7 @@ exports.g = {
|
|||||||
typedoc: require("gulp-typedoc")
|
typedoc: require("gulp-typedoc")
|
||||||
};
|
};
|
||||||
exports.lodashObject = require('lodash/fp/object');
|
exports.lodashObject = require('lodash/fp/object');
|
||||||
|
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");
|
||||||
|
2
dist/npmts.tests.js
vendored
2
dist/npmts.tests.js
vendored
@ -31,7 +31,7 @@ var mocha = function (configArg) {
|
|||||||
.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',
|
dir: plugins.path.join(paths.cwd, "./coverage"),
|
||||||
reporters: ['lcovonly', 'json', 'text', 'text-summary']
|
reporters: ['lcovonly', 'json', 'text', 'text-summary']
|
||||||
}))
|
}))
|
||||||
.pipe(plugins.g.gFunction(function () {
|
.pipe(plugins.g.gFunction(function () {
|
||||||
|
11
package.json
11
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "5.3.21",
|
"version": "5.3.25",
|
||||||
"description": "write npm modules with TypeScript",
|
"description": "Write npm modules with TypeScript without hassle. TypeScript ready. Fully ES6.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"npmts": "dist/cli.js"
|
"npmts": "dist/cli.js"
|
||||||
@ -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",
|
||||||
|
@ -8,10 +8,14 @@ export var run = function(configArg){
|
|||||||
let config = configArg;
|
let config = configArg;
|
||||||
npmtsOra.text("now looking at " + "required assets".yellow);
|
npmtsOra.text("now looking at " + "required assets".yellow);
|
||||||
if(config.cli == true){
|
if(config.cli == true){
|
||||||
plugins.smartfile.fs.copy(plugins.path.join(paths.npmtsAssetsDir,"cli.js"),paths.distDir);
|
plugins.smartfile.fs.copySync(
|
||||||
|
plugins.path.join(paths.npmtsAssetsDir,"cli.js"),
|
||||||
|
plugins.path.join(paths.distDir,"cli.js")
|
||||||
|
);
|
||||||
plugins.beautylog.ok("installed CLI assets!");
|
plugins.beautylog.ok("installed CLI assets!");
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
} else {
|
} else {
|
||||||
|
plugins.beautylog.ok("No additional assets required!")
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
}
|
}
|
||||||
return done.promise;
|
return done.promise;
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
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 = {
|
||||||
|
mode: "default",
|
||||||
|
notest:false
|
||||||
|
};
|
||||||
if(argvArg.notest){
|
if(argvArg.notest){
|
||||||
config.notest = true;
|
defaultConfig.notest = true;
|
||||||
}
|
};
|
||||||
if(plugins.smartfile.fs.fileExistsSync(configPath)){
|
let config = plugins.npmextra.dataFor({
|
||||||
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
toolName:"npmts",
|
||||||
config = plugins.lodashObject.assign(
|
defaultSettings:defaultConfig,
|
||||||
config,
|
cwd:paths.cwd
|
||||||
plugins.smartfile.fs.toObjectSync(configPath)
|
});
|
||||||
);
|
|
||||||
switch (config.mode){
|
switch (config.mode){
|
||||||
case "default":
|
case "default":
|
||||||
case "custom":
|
case "custom":
|
||||||
@ -24,10 +27,6 @@ export var run = function(argvArg){
|
|||||||
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
|
||||||
config.mode = "default";
|
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
};
|
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
@ -12,6 +12,7 @@ export let g = {
|
|||||||
typedoc: require("gulp-typedoc")
|
typedoc: require("gulp-typedoc")
|
||||||
};
|
};
|
||||||
export let lodashObject = require('lodash/fp/object');
|
export let lodashObject = require('lodash/fp/object');
|
||||||
|
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");
|
||||||
|
@ -32,7 +32,7 @@ let mocha = function (configArg) {
|
|||||||
.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',
|
dir: plugins.path.join(paths.cwd,"./coverage"),
|
||||||
reporters: [ 'lcovonly', 'json', 'text', 'text-summary']
|
reporters: [ 'lcovonly', 'json', 'text', 'text-summary']
|
||||||
}))
|
}))
|
||||||
.pipe(plugins.g.gFunction(function(){
|
.pipe(plugins.g.gFunction(function(){
|
||||||
|
Reference in New Issue
Block a user