Generate project with yo node-typescript, modifes gitignore by hand

This commit is contained in:
Abhas Bhattacharya
2018-01-26 20:35:07 +05:30
parent c1b27b38cc
commit 12feed4fa7
17 changed files with 3370 additions and 7 deletions
+12
View File
@@ -0,0 +1,12 @@
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
+15
View File
@@ -1,3 +1,18 @@
# Project specific
# -------------------
coverage/
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.nyc_output
lib
lib_test
# Generic
# ---------------
# Logs
logs
*.log
+16
View File
@@ -0,0 +1,16 @@
# gitignore
coverage/
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.nyc_output
lib
lib_test
# npmignore
src/
__tests__/
.vscode/
+7
View File
@@ -0,0 +1,7 @@
language: node_js
node_js:
- 'node' # use latest stable nodejs version
script:
- npm run coverage # jest test with coverage flag does coverage too
after_script:
- 'cat coverage/lcov.info | ./node_modules/.bin/coveralls' # sends the coverage report to coveralls
+34
View File
@@ -0,0 +1,34 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug file",
"program": "${workspaceRoot}/lib/${fileBasenameNoExtension}.js",
"cwd": "${workspaceRoot}",
"sourceMaps": true,
"smartStep": true,
"preLaunchTask": "build",
"outFiles": [
"${workspaceRoot}/lib/*.js"
]
},
{
"type": "node",
"request": "launch",
"name": "Debug test",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"args": [
"--findRelatedTests",
"${relativeFile}",
"--env",
"jest-environment-node-debug"
],
"cwd": "${workspaceRoot}"
}
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib/"
}
+59
View File
@@ -0,0 +1,59 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "Run current file",
"command": "ts-node ${relativeFile}",
"type": "shell",
"problemMatcher": []
},
{
"type": "npm",
"label": "clean",
"script": "clean",
"problemMatcher": []
},
{
"type": "npm",
"label": "build",
"script": "build",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher":[]
},
{
"type": "npm",
"label": "format",
"script": "format",
"problemMatcher": []
},
{
"type": "npm",
"label": "coverage",
"script": "coverage",
"problemMatcher": []
},
{
"type": "npm",
"label": "test",
"script": "test",
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": []
},
{
"type": "npm",
"label": "lint",
"script": "lint",
"problemMatcher": [
"$eslint-stylish"
]
}
]
}
+6 -6
View File
@@ -1,6 +1,6 @@
MIT License
The MIT License (MIT)
Copyright (c) 2018 Abhas Bhattacharya
Copyright (c) 2018
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ 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 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.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+34 -1
View File
@@ -1 +1,34 @@
# tbl
[![Build Status](https://travis-ci.org/{{github-user-name}}/{{github-app-name}}.svg?branch=master)](https://travis-ci.org/{{github-user-name}}/{{github-app-name}}.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/{{github-user-name}}/{{github-app-name}}/badge.svg?branch=master)](https://coveralls.io/github/{{github-user-name}}/{{github-app-name}}?branch=master)
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
# Using this module in other modules
Here is a quick example of how this module can be used in other modules. The [TypeScript Module Resolution Logic](https://www.typescriptlang.org/docs/handbook/module-resolution.html) makes it quite easy. The file `src/index.ts` is a [barrel](https://basarat.gitbooks.io/typescript/content/docs/tips/barrel.html) that re-exports selected exports from other files. The _package.json_ file contains `main` attribute that points to the generated `lib/index.js` file and `typings` attribute that points to the generated `lib/index.d.ts` file.
> If you are planning to have code in multiple files (which is quite natural for a NodeJS module) that users can import, make sure you update `src/index.ts` file appropriately.
Now assuming you have published this amazing module to _npm_ with the name `my-amazing-lib`, and installed it in the module in which you need it -
- To use the `Greeter` class in a TypeScript file -
```ts
import { Greeter } from "my-amazing-lib";
const greeter = new Greeter("World!");
greeter.greet();
```
- To use the `Greeter` class in a JavaScript file -
```js
const Greeter = require('my-amazing-lib').Greeter;
const greeter = new Greeter('World!');
greeter.greet();
```
## Setting travis and coveralls badges
1. Sign in to [travis](https://travis-ci.org/) and activate the build for your project.
2. Sign in to [coveralls](https://coveralls.io/) and activate the build for your project.
3. Replace {{github-user-name}}/{{github-app-name}} with your repo details like: "ospatil/generator-node-typescript".
+6
View File
@@ -0,0 +1,6 @@
import { Greeter } from '../src/greeter';
test('Should greet with message', () => {
const greeter = new Greeter('friend');
expect(greeter.greet()).toBe('Bonjour, friend!');
});
+5
View File
@@ -0,0 +1,5 @@
import * as index from '../src/index';
test('Should have Greeter available', () => {
expect(index.Greeter).toBeTruthy();
});
+57
View File
@@ -0,0 +1,57 @@
{
"name": "tbl",
"version": "0.0.0",
"description": "tbl",
"license": "MIT",
"repository": "",
"author": {
"name": "",
"email": "",
"url": ""
},
"keywords": [""],
"files": ["lib"],
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"scripts": {
"clean": "rimraf lib && rimraf coverage",
"format":
"prettier --write \"{src,__tests__}/**/*.ts\" --single-quote --trailing-comma es5",
"lint": "tslint --force --format verbose \"src/**/*.ts\"",
"prepare": "npm run build",
"prebuild":
"npm run clean && npm run format && npm run lint && echo Using TypeScript && tsc --version",
"build": "tsc --pretty",
"test": "jest",
"coverage": "jest --coverage",
"watch": "npm run build -- --watch",
"watch:test": "jest --watch"
},
"dependencies": {},
"devDependencies": {
"@types/jest": "^22.0.1",
"@types/node": "^8.0.0",
"coveralls": "^2.0.0",
"jest": "^22.0.4",
"jest-environment-node-debug": "^2.0.0",
"prettier": "^1.5.2",
"rimraf": "^2.0.0",
"ts-jest": "^22.0.1",
"ts-node": "^3.2.0",
"tslint": "^5.0.0",
"tslint-config-prettier": "^1.1.0",
"typescript": "^2.3.0"
},
"engines": {
"node": ">=6.0.0"
},
"jest": {
"transform": {
".(ts)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|js)$",
"moduleFileExtensions": ["ts", "js"],
"testEnvironment": "node",
"mapCoverage": true
}
}
+11
View File
@@ -0,0 +1,11 @@
export class Greeter {
private greeting: string;
constructor(message: string) {
this.greeting = message;
}
public greet(): string {
return `Bonjour, ${this.greeting}!`;
}
}
+1
View File
@@ -0,0 +1 @@
export * from './greeter';
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"declaration": true,
"module": "commonjs",
"moduleResolution": "node",
"lib": [
"esnext"
],
"target": "es2015",
"strict": true,
"outDir": "./lib",
"preserveConstEnums": true,
"removeComments": true,
"inlineSourceMap": true,
"typeRoots": [
"./node_modules/@types"
]
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"**/*-spec.ts"
]
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": [
"tslint:latest",
"tslint-config-prettier"
]
}
+3072
View File
File diff suppressed because it is too large Load Diff