-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base files with Typescript
- Loading branch information
0 parents
commit 8ad0163
Showing
16 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
coverage/ | ||
node_modules/ | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib/" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"version": "0.1.0", | ||
"command": "npm", | ||
"isShellCommand": true, | ||
"args": ["run"], | ||
"showOutput": "always", | ||
"tasks": [ | ||
{ | ||
"taskName": "build", | ||
"isBuildCommand": true | ||
}, | ||
{ | ||
"taskName": "clean" | ||
}, | ||
{ | ||
"taskName": "lint" | ||
}, | ||
{ | ||
"taskName": "test", | ||
"isTestCommand": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 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` acts as an aggregator of all the functionality in this module. It imports from other files and re-exports to provide a unified interface for this module. 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(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export declare class Greeter { | ||
private greeting; | ||
constructor(message: string); | ||
greet(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use strict"; | ||
var Greeter = (function () { | ||
function Greeter(message) { | ||
this.greeting = message; | ||
} | ||
Greeter.prototype.greet = function () { | ||
return "Bonjour, " + this.greeting + "!"; | ||
}; | ||
return Greeter; | ||
}()); | ||
exports.Greeter = Greeter; | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { Greeter } from "./greeter"; | ||
export { Greeter }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"use strict"; | ||
var greeter_1 = require("./greeter"); | ||
exports.Greeter = greeter_1.Greeter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "scaffolding-all", | ||
"version": "0.0.0", | ||
"description": "Scaffold your application based on an documentation", | ||
"license": "MIT", | ||
"repository": "", | ||
"files": [ | ||
"lib" | ||
], | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"scripts": { | ||
"clean": "rimraf lib", | ||
"lint": "tslint --force --format verbose \"src/**/*.ts\"", | ||
"build": "npm run clean && npm run lint && echo Using TypeScript && tsc --version && tsc --pretty", | ||
"test": "npm run build && mocha --compilers ts:ts-node/register --recursive test/**/*-spec.ts", | ||
"watch": "npm run build -- --watch", | ||
"watch:test": "npm run test -- --watch" | ||
}, | ||
"keywords": [ | ||
"scaffold", | ||
"yeoman-generator" | ||
], | ||
"author": "[email protected]", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/chai": "^3.0.0", | ||
"@types/json5": "0.0.29", | ||
"@types/mocha": "^2.0.0", | ||
"@types/node": "6.0.31", | ||
"chai": "^3.0.0", | ||
"json5": "^0.5.1", | ||
"mocha": "^3.0.0", | ||
"rimraf": "^2.0.0", | ||
"ts-node": "^1.0.0", | ||
"tslint": "^4.0.0", | ||
"typescript": "^2.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=4.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export class Greeter { | ||
private greeting: string; | ||
|
||
constructor(message: string) { | ||
this.greeting = message; | ||
} | ||
|
||
public greet() { | ||
return "Bonjour, " + this.greeting + "!"; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { json5 } from "json5"; | ||
import { Greeter } from "./greeter"; | ||
|
||
export { Greeter }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
import { Greeter } from "../src/greeter"; | ||
import * as chai from "chai"; | ||
|
||
const expect = chai.expect; | ||
|
||
describe("greeter", () => { | ||
it("should greet with message", () => { | ||
const greeter = new Greeter("friend"); | ||
expect(greeter.greet()).to.equal("Bonjour, friend!"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noImplicitAny": true, | ||
"outDir": "./lib", | ||
"preserveConstEnums": true, | ||
"removeComments": true | ||
}, | ||
"include": [ | ||
"src/**/*" | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"**/*-spec.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "tslint:latest" | ||
} |