Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
63c73536a2 | |||
2f7ebfc47a | |||
372d2605bb | |||
2ecf6c00b8 | |||
2f3d8cecd3 | |||
54bbab232e | |||
380407b5e8 |
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;
|
||||||
|
10
package.json
10
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "5.3.23",
|
"version": "5.3.26",
|
||||||
"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"
|
||||||
@ -47,7 +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",
|
"npmextra": "^1.0.8",
|
||||||
"projectinfo": "1.0.3",
|
"projectinfo": "1.0.3",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"shelljs": "^0.7.0",
|
"shelljs": "^0.7.0",
|
||||||
@ -55,9 +55,9 @@
|
|||||||
"smartcli": "1.0.4",
|
"smartcli": "1.0.4",
|
||||||
"smartcov": "0.0.6",
|
"smartcov": "0.0.6",
|
||||||
"smartenv": "1.2.5",
|
"smartenv": "1.2.5",
|
||||||
"smartfile": "4.0.10",
|
"smartfile": "4.0.12",
|
||||||
"smartpath": "3.2.2",
|
"smartpath": "3.2.2",
|
||||||
"smartstring": "^2.0.14",
|
"smartstring": "^2.0.15",
|
||||||
"source-map-support": "^0.4.2",
|
"source-map-support": "^0.4.2",
|
||||||
"tsn": "^1.0.7",
|
"tsn": "^1.0.7",
|
||||||
"typedoc": "^0.4.4",
|
"typedoc": "^0.4.4",
|
||||||
|
@ -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;
|
||||||
|
Reference in New Issue
Block a user