commit
3b1d08bf35
44
.env.dist
Normal file
44
.env.dist
Normal file
@ -0,0 +1,44 @@
|
||||
MSSQL_Skip=0
|
||||
MSSQL_Host=localhost
|
||||
MSSQL_Port=1433
|
||||
MSSQL_Username=sa
|
||||
MSSQL_Password=Admin12345
|
||||
MSSQL_Database=typeorm_mg
|
||||
MSSQL_SSL=0
|
||||
|
||||
POSTGRES_Skip=0
|
||||
POSTGRES_Host=localhost
|
||||
POSTGRES_Port=5432
|
||||
POSTGRES_Username=test
|
||||
POSTGRES_Password=test
|
||||
POSTGRES_Database=test
|
||||
POSTGRES_SSL=0
|
||||
|
||||
MYSQL_Skip=0
|
||||
MYSQL_Host=localhost
|
||||
MYSQL_Port=3306
|
||||
MYSQL_Username=root
|
||||
MYSQL_Password=admin
|
||||
MYSQL_Database=test
|
||||
MYSQL_SSL=0
|
||||
|
||||
MARIADB_Skip=0
|
||||
MARIADB_Host=localhost
|
||||
MARIADB_Port=3307
|
||||
MARIADB_Username=root
|
||||
MARIADB_Password=admin
|
||||
MARIADB_Database=test
|
||||
MARIADB_SSL=0
|
||||
|
||||
ORACLE_Skip=0
|
||||
ORACLE_Host=localhost
|
||||
ORACLE_Port=1521
|
||||
ORACLE_SSL=0
|
||||
ORACLE_UsernameSys=sys
|
||||
ORACLE_PasswordSys=Oradoc_db1
|
||||
ORACLE_Database=orclpdb1.localdomain
|
||||
ORACLE_Username=typeorm_mg
|
||||
ORACLE_Password=Passw0rd
|
||||
|
||||
SQLITE_Skip=0
|
||||
SQLITE_Database=./sqlitedb.db
|
51
CONTRIBUTING.md
Normal file
51
CONTRIBUTING.md
Normal file
@ -0,0 +1,51 @@
|
||||
# Contributing to typeorm-model-generator
|
||||
|
||||
|
||||
- [Question or Problem?](#question)
|
||||
- [Submission Guidelines](#submit)
|
||||
|
||||
|
||||
|
||||
## <a name="question"></a> Got a Question or Problem?
|
||||
* You can create issue on [github](https://github.com/Kononnable/typeorm-model-generator/issues)
|
||||
* While this tool doesn't have separate separate chat room you can use [typeorm slack workspace](https://join.slack.com/t/typeorm/shared_invite/enQtNDQ1MzA3MDA5MTExLTFiNDEyOGUxZGQyYWIwOTA0NDQxODdkOGQ0OTUxNzFjYjUwY2E0ZmFlODc5OTYyYzAzNGM3MGZjYzhjYTBiZTY) since everyone using typeorm-model-generator will also use typeorm.
|
||||
|
||||
|
||||
|
||||
## <a name="submit"></a> Submission Guidelines
|
||||
|
||||
### <a name="submit-issue"></a> Submitting an Issue
|
||||
|
||||
Before submitting new issue, please check the issue tracker, maybe your problem is already described and the discussion might inform you of available workarounds.
|
||||
|
||||
Before fixing a bug we need to reproduce and confirm it. In order to reproduce bugs, we will ask you to provide a minimal reproduction. Having a minimal reproducible scenario gives us a wealth of important information without going back & forth to you with additional questions. A minimal reproduction allows us to quickly confirm a bug (or point out a coding problem) as well as confirm that we are fixing the right problem.
|
||||
|
||||
### <a name="submit-pr"></a> Submitting a Pull Request (PR)
|
||||
Before you submit your Pull Request (PR) consider the following guidelines:
|
||||
|
||||
1. Search [GitHub](https://github.com/Kononnable/typeorm-model-generator/pulls) for an open or closed PR that relates to your submission. You don't want to duplicate effort.
|
||||
1. Make your changes in a new git branch:
|
||||
|
||||
```shell
|
||||
git checkout -b my-fix-branch master
|
||||
```
|
||||
|
||||
1. Create your patch.
|
||||
1. Run test suite and ensure that all tests pass.
|
||||
1. Commit your changes using a descriptive commit message.
|
||||
|
||||
1. Push your branch to GitHub:
|
||||
|
||||
```shell
|
||||
git push origin my-fix-branch
|
||||
```
|
||||
|
||||
1. In GitHub, send a pull request to `typeorm-model-generator:master`.
|
||||
* If we suggest changes then:
|
||||
* Make the required updates.
|
||||
* Re-run test suites to ensure tests are still passing.
|
||||
* Push to your GitHub repository (this will update your Pull Request)
|
||||
|
||||
Note: if you don't want to run tests on your machine you can rely on tests run on CI (unless you're changing something oracledb specific).
|
||||
|
||||
That's it! Thank you for your contribution!
|
30
DEVELOPER.md
Normal file
30
DEVELOPER.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Setting up environment
|
||||
## Building
|
||||
After cloning the repository you can check your changes made to source code without compiling whole library. Just run `npm start` to run typeorm-model-generator through ts-node. It helps with development speed and avoids problem with setting correct sourcemaps when debugging.
|
||||
|
||||
However if you want to build typeorm-model-generator you can do this by running:
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
It might come handy if you want to build full pipeline workflow with model generator and install it through `npm link`.
|
||||
## Running Tests Locally
|
||||
To run tests you need to have docker and docker-compose installed. You may also use non-dockerized database servers but it's not recommended - they might use non-default database engine settings.
|
||||
### Oracle Database
|
||||
If you want to run oracle tests locally you must have [oracle client](https://oracle.github.io/node-oracledb/INSTALL.html#quickstart) configured for your machine and accepted oracle license on [DockerHub](https://hub.docker.com/_/oracle-database-enterprise-edition). Because of oracle client limitations i.e. it's not distributed for 32bit environments you have to install oracledb manually:
|
||||
```
|
||||
npm install oracledb --no-save
|
||||
```
|
||||
### Configuration
|
||||
Tests use environment values to provide credentials for connecting to multiple database engines. For developer convenience there is prepared env file with default connection settings(for connecting to dockerized db engines). After cloning the repo you just need to rename the env file:
|
||||
```
|
||||
cp .env.dist .env
|
||||
```
|
||||
### Database engines
|
||||
Next you have to start db engines. If you want to test all of the drivers and have configured oracle correctly you can just:
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
You can also start just specific database engines e.g.:
|
||||
```
|
||||
docker-compose up -d mysql postgres mariadb
|
||||
```
|
@ -82,6 +82,8 @@ Options:
|
||||
```
|
||||
npx typeorm-model-generator -d "Z:\sqlite.db" -e sqlite -o .
|
||||
````
|
||||
## Use Cases
|
||||
Please take a look at [few workflows](USECASES.md) which might help you with deciding how you're gonna use typeorm-model-generator.
|
||||
## Naming strategy
|
||||
If you want to generate custom names for properties in generated entities you need to use custom naming strategy. You need to create your own version of [NamingStrategy](https://github.com/Kononnable/typeorm-model-generator/blob/master/src/NamingStrategy.ts) and pass it as command parameter.
|
||||
|
||||
|
53
USECASES.md
Normal file
53
USECASES.md
Normal file
@ -0,0 +1,53 @@
|
||||
# Common use cases
|
||||
Typeorm-model-generator can be used in multiple workflows. Here are described few recommended ones.
|
||||
## Use directly from npm
|
||||
You can use typeorm-model-generator directly from npm:
|
||||
```
|
||||
npx typeorm-model-generator
|
||||
```
|
||||
Please remember that by using `npx typeorm-model-generator` you will download latest available version. To avoid it you can specify version each time `npx typeorm-model-generator@0.3.0` or install a package locally - npx will use locally installed version then.
|
||||
### command line parameters
|
||||
You can customize generated output by specifying multiple parameters. Full list of parameters are available through `npx typeorm-model-generator --help`
|
||||
### config file
|
||||
If you execute `npx typeorm-model-generator` without specifying any parameters you will enter a wizard mode which will guide you through specifying connection settings and allow to customize generated models. At the end of this process you will be able to save your settings, so the process will run automatically next time.
|
||||
## clone repo and make manual changes
|
||||
If you need more power over how models are generated you can fork the repo and make changes to the code which are specific to your use case.
|
||||
- fork the repo
|
||||
- clone forked repo locally
|
||||
- create branch for your changes:
|
||||
```
|
||||
git checkout -b my-branch master
|
||||
```
|
||||
- add remote repository:
|
||||
```
|
||||
git remote add upstream https://github.com/Kononnable/typeorm-model-generator.git
|
||||
```
|
||||
You can run model generation tool by running `npm run start` after installing dependencies.
|
||||
|
||||
When you want to download changes made on main typeorm-model-generator repo just
|
||||
- checkout `master` branch
|
||||
- download changes from main repository:
|
||||
```
|
||||
git pull --ff upstream master
|
||||
```
|
||||
- checkout branch with your changes:
|
||||
```
|
||||
git checkout my-branch
|
||||
```
|
||||
- merge changes onto your branch:
|
||||
```
|
||||
git merge master
|
||||
```
|
||||
|
||||
## git repo with dependency and entire pipeline
|
||||
Similar to previous workflow, but this time we don't have to worry about manually merging changes from main repository.
|
||||
- Init new package:
|
||||
```
|
||||
npm init -y
|
||||
```
|
||||
- Install typeorm-model-generator as a dependency:
|
||||
```
|
||||
npm install typeorm-model-generator
|
||||
```
|
||||
- Write code which loads generated entity files and change its content
|
||||
- Run typeorm-model-generator, then your code which customizes it (you may add this step to `package.json` scripts section)
|
@ -5,7 +5,7 @@
|
||||
"bin": "bin/typeorm-model-generator",
|
||||
"scripts": {
|
||||
"start": "ts-node ./src/index.ts",
|
||||
"build": "tsc && ncp src/entity.mst dist/src/entity.mst",
|
||||
"build": "npm run clean && tsc && ncp src/entity.mst dist/src/entity.mst",
|
||||
"prepare": "npm run build",
|
||||
"pretest": "tsc --noEmit",
|
||||
"test": "nyc --reporter=lcov ts-node ./node_modules/mocha/bin/_mocha test/**/*.test.ts -- -R spec --bail",
|
||||
|
Loading…
Reference in New Issue
Block a user