readme, preparation to npm publish

This commit is contained in:
Kononnable 2017-07-20 23:16:55 +02:00
parent 4ea92725e0
commit 36d66ae483
6 changed files with 79 additions and 5 deletions

3
.gitignore vendored
View File

@ -9,4 +9,5 @@ output/**/*.*
.nyc_output/
coverage/
.env
dist
dist
*.tgz

View File

@ -1 +1,22 @@
tests/**/*
node_modules/
npm-debug.log
ormconfig.json
.vscode
typings/
**/*.js.map
output/**/*.*
.nyc_output/
coverage/
.env
*.tgz
!src/
src/*
!src/*.mst
test/
.travis.yml
codecov.yml
tsconfig.json
typings.json
dist/test/

View File

@ -3,6 +3,51 @@
[![npm version](https://badge.fury.io/js/typeorm-model-generator.svg)](https://badge.fury.io/js/typeorm-model-generator)
[![codecov](https://codecov.io/gh/Kononnable/typeorm-model-generator/branch/master/graph/badge.svg)](https://codecov.io/gh/Kononnable/typeorm-model-generator)
Generates models for TypeORM from existing databases.
Generates models for TypeORM from existing databases.
Suported db engines:
* Microsoft SQL Server
* PostgreSQL
*Work in progress*
## Installation
### Global module
To install module globally simply type `npm i -g typeorm-model-generator` in your console.
### Npx way
Thanks to npx you can use npm modules without polluting global installs. So nothing to do here :)
>To use `npx` you need to use npm at version at least 5.2.0. Try updating your npm by `npm i -g npm`
## Usage
```shell
Usage: typeorm-model-generator -h <host> -d <database> -p [port] -u <user> -x
[password] -e [engine]
Options:
-h, --host IP adress/Hostname for database server. [required]
-d, --database Database name. [required]
-u, --user Username for database server. [required]
-x, --pass Password for database server. [required]
-p, --port Port number for database server.
-e, --engine Database engine. [choices: "mssql", "postgres"]
-o, --output Where to place generated models.
```
### Examples
* Creating model from local MSSQL database
* Global module
```
typeorm-model-generator -h localhost -d tempdb -u sa -x !Passw0rd -e mssql -o .\
````
* Npx Way
```
npx typeorm-model-generator -h localhost -d tempdb -u sa -x !Passw0rd -e mssql -o .\
````
* Creating model from local Postgres database
* Global module
```
typeorm-model-generator -h localhost -d postgres -u postgres -x !Passw0rd -e postgres -o .\
````
* Npx Way
```
npx typeorm-model-generator -h localhost -d postgres -u postgres -x !Passw0rd -e postgres -o .\
````

View File

@ -0,0 +1,6 @@
#!/usr/bin/env node
'use strict';
require('../dist/src/index');

View File

@ -2,6 +2,7 @@
"name": "typeorm-model-generator",
"version": "0.0.1",
"description": "Generates models for TypeORM from existing databases.",
"bin": "bin/typeorm-model-generator",
"scripts": {
"tsc:w": "tsc -w",
"tsc": "tsc",

View File

@ -25,7 +25,7 @@ export class Engine {
}
private createModelFromMetadata(databaseModel: DatabaseModel) {
let templatePath = path.resolve(process.cwd(), 'src/entity.mst')
let templatePath = path.resolve(__dirname, '../../src/entity.mst')
let template = fs.readFileSync(templatePath, 'UTF-8');
let resultPath = this.Options.resultsPath
if (!fs.existsSync(resultPath))