typeorm-uml icon indicating copy to clipboard operation
typeorm-uml copied to clipboard

[Question] Generate UML diagram from ts file

Open adarshaacharya opened this issue 3 years ago • 2 comments

Since typeorm supports .ts file for configuring ORM, is it possible to generate the ER diagram from that file too.. or just json file is supported.

adarshaacharya avatar Oct 25 '21 03:10 adarshaacharya

But I just came across https://github.com/typeorm/typeorm/issues/7427 which suggests the entire ormconfig.* system is being modified (perhaps deprecated?) so that may impact how this tool works.

ianstokesrees-gamma avatar Nov 09 '21 12:11 ianstokesrees-gamma

Hi,

typeorm-uml leverages typeorm. Thus, as long as typeorm supports those formats, I believe this library should too.

I am currently using typeorm-uml exclusively using ormconfig.ts files. Hence, it should also work on your end.

The easiest/minimalistic way to set this up is as follows:

  1. Install ts-node if not already leveraged in your project (any alternative to ts-node may also work)
yarn add ts-node --dev
  1. Edit your package.json to create some scripts to easily generate the diagram
"scripts": {
  "typeorm-uml": "node --require ts-node/register node_modules/typeorm-uml/bin/run"
  "database:diagram": "yarn typeorm-uml <yourOptions> <path/to/ormconfig.ts>"
}
  1. Generate your diagram:
yarn database:diagram

julien-sugg avatar Apr 20 '22 08:04 julien-sugg