mirror of
https://github.com/bendtherules/react-to-markdown.git
synced 2026-08-18 13:53:11 +00:00
Create project scaffolding using yo node-typescript
This commit is contained in:
@@ -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
|
||||
@@ -0,0 +1,8 @@
|
||||
coverage/
|
||||
node_modules/
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.nyc_output
|
||||
lib
|
||||
lib_test
|
||||
+16
@@ -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/
|
||||
@@ -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
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
{
|
||||
// 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}"
|
||||
],
|
||||
"cwd": "${workspaceRoot}"
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib/"
|
||||
}
|
||||
Vendored
+59
@@ -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": [
|
||||
{
|
||||
"label": "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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
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 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.
|
||||
@@ -0,0 +1,34 @@
|
||||
[](https://travis-ci.org/{{github-user-name}}/{{github-app-name}}.svg?branch=master)
|
||||
[](https://coveralls.io/github/{{github-user-name}}/{{github-app-name}}?branch=master)
|
||||
[](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".
|
||||
@@ -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!');
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
import * as index from '../src/index';
|
||||
|
||||
test('Should have Greeter available', () => {
|
||||
expect(index.Greeter).toBeTruthy();
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "react-to-markdown",
|
||||
"version": "0.0.1",
|
||||
"description": "react-to-markdown",
|
||||
"license": "MIT",
|
||||
"repository": "",
|
||||
"author": {
|
||||
"name": "",
|
||||
"email": "",
|
||||
"url": ""
|
||||
},
|
||||
"keywords": [
|
||||
""
|
||||
],
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"main": "lib/index",
|
||||
"types": "lib/index",
|
||||
"scripts": {
|
||||
"clean": "rimraf lib && rimraf coverage",
|
||||
"format": "prettier --write \"{src,__tests__}/**/*.ts\" --single-quote --trailing-comma es5",
|
||||
"lint": "tslint --force --format verbose \"src/**/*.ts\"",
|
||||
"prepublishOnly": "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": "^23.3.3",
|
||||
"@types/node": "^10.11.4",
|
||||
"coveralls": "^3.0.2",
|
||||
"jest": "^23.6.0",
|
||||
"prettier": "^1.14.3",
|
||||
"rimraf": "^2.6.2",
|
||||
"ts-jest": "^23.10.3",
|
||||
"ts-node": "^7.0.1",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-config-prettier": "^1.15.0",
|
||||
"typescript": "^3.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export class Greeter {
|
||||
private greeting: string;
|
||||
|
||||
constructor(message: string) {
|
||||
this.greeting = message;
|
||||
}
|
||||
|
||||
public greet(): string {
|
||||
return `Bonjour, ${this.greeting}!`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './greeter';
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"lib": [
|
||||
"esnext"
|
||||
],
|
||||
"target": "es2015",
|
||||
"outDir": "./lib",
|
||||
"removeComments": true,
|
||||
"inlineSourceMap": true,
|
||||
"inlineSources": true,
|
||||
"preserveConstEnums": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"**/*-spec.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": [
|
||||
"tslint:latest",
|
||||
"tslint-config-prettier"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user