Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #14 from eugene-manuilov/develop
Browse files Browse the repository at this point in the history
Develop changes
  • Loading branch information
eugene-manuilov authored Nov 12, 2020
2 parents 2ba776c + 54803bb commit 9e7fcc3
Show file tree
Hide file tree
Showing 27 changed files with 3,908 additions and 479 deletions.
35 changes: 35 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
exports.env = {
es2020: true,
node: true,
jest: true,
};

exports.parser = '@typescript-eslint/parser';
exports.parserOptions = {
ecmaVersion: 11,
sourceType: 'module'
};

exports.extends = [
'standard',
];

exports.plugins = [
'@typescript-eslint',
];

exports.rules = {
'@typescript-eslint/no-unused-vars': [ 'error' ],
'array-bracket-spacing': [ 'error', 'always' ],
'comma-dangle': [ 'error', { arrays: 'always-multiline', objects: 'always-multiline' } ],
'indent': [ 'error', 'tab', { SwitchCase: 1 } ],
'no-console': 'error',
'no-tabs': 'off',
'no-unused-vars': 'off',
'no-useless-constructor': 'off',
'padded-blocks': [ 'error', { classes: 'always' } ],
'semi': [ 'error', 'always' ],
'space-before-function-paren': [ 'error', { named: 'never' } ],
'space-in-parens': [ 'error', 'always' ],
'template-curly-spacing': [ 'error', 'always' ],
};
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ jobs:
working-directory: example
run: test "$(../bin/run)" = "$EXPECTED"
env:
EXPECTED: http://www.plantuml.com/plantuml/png/bP5BIyD054RNpg_uZ9kCMYH2Do4C3MAn6nSbYBiowTpQmSc3p1KIIl-xJL_KGaLdUU_Xd1bcv5at_5Ku8QuDBMn9O9qx2bk9kTFUeqMI8CpkRyRZT7Cab3gYzITrFPdagaqUSYMMrX0yKqCLTpNvtM1XoHalnCwCkMRwg9eE4YjnjIg8bvLPusvhWpMGCIQlMHX5ycHTwe9YlANJfvTq6ZuEXrAiZygwylm_7LjsvxwJBRKS8tj-pyuYi_tbBVdPx-_ewSc5-1uv27vYc-35Kd0RO31G2A9W6_WRUHWACQBIz9_z3G00
EXPECTED: http://www.plantuml.com/plantuml/png/XP7DQiCm48Jl-nHRUh5eGqaX5sDCJ6beBZa4KteBShHjH6p9I1kmgVFkbVC7DMsYctPclXtOgMVfU5UL07UAFhKXhBVKHet0f4YRvAb8BmBBegHU8SEQMsmmIJ3A7-zdiomyWMaAiD6Aq3CvijpMv8-3YdXZbGVmMsrgwMI5PK3s3hGkQ017EgubqvTrBGhy1iI7GnlK2aMCyqKUZSSYZ8siACRtRFdobYsZvyb4mFw2gAtdw_5GlnpcmvGQZZ5__SW7iDMfb2Q_-hjVxveFbfoaS-2t71RyIzvter7N7PWtJUS_m9ICwk_u0m00
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/node_modules/
/lib/
/examples/**/node_modules/
/examples/**/*.js
/examples/**/*.js.map
/tsconfig.tsbuildinfo
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8
15 changes: 15 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Project",
"type": "shell",
"command": "npm",
"args": ["run", "build"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
32 changes: 26 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
# Changelog

## v1.2.1 (2020-06-18)
## [Unreleased] - TBD
-

## [v1.3.0] (2020-11-12)
- Added an example with a shopping cart database.
- Updated builder to throw an error if no entities have been found.
- Updated builder to use entities instead of classes.
- Updated builder to use entity relationships.
- Fixed issues when the absolute path to the config file was used.
- Fixed issues with foreign keys when sometimes foreign keys were defined before referencing tables.

## [v1.2.1] (2020-06-18)
- Fixed puml diagram downloading issue.

## v1.2.0 (2020-06-18)
## [v1.2.0] (2020-06-18)
- Added GitHub Actions to check build process on push.
- Added GitHub Actions to check generated UML.
- Added puml format that displays generated UML code.
- Reworked typeorm configuration read to skip connecting to the database.
- Fixed primary column formatting for TXT format (removed HTML tag).

## v1.1.3 (2020-05-25)
## [v1.1.3] (2020-05-25)
- Fixed typo in the readme file.
- Updated dependencies to the latest versions.

## v1.1.2 (2020-01-11)
## [v1.1.2] (2020-01-11)
- Fixed UML generation issue.

## v1.1.1 (2020-01-11)
## [v1.1.1] (2020-01-11)

- Fixed build command issue.

## v1.1.0 (2020-01-11)
## [v1.1.0] (2020-01-11)

- Added `--download` option to download a diagram.
- Added `--include` option to include only specific entities to the diagram.
- Added `--exclude` option to exclude specific entities from the diagram.

[Unreleased]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.3.0...master
[v1.3.0]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.2.1...v1.3.0
[v1.2.1]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.2.0...v1.2.1
[v1.2.0]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.1.3...v1.2.0
[v1.1.3]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.1.2...v1.1.3
[v1.1.2]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.1.1...v1.1.2
[v1.1.1]: https://github.com/eugene-manuilov/typeorm-uml/compare/v1.1.0...v1.1.1
[v1.1.0]: https://github.com/eugene-manuilov/typeorm-uml/releases/tag/v1.1.0
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# typeorm-uml 1.2.1
# typeorm-uml 1.3.0

[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/typeorm-uml.svg)](https://www.npmjs.com/package/typeorm-uml)
[![Downloads/week](https://img.shields.io/npm/dw/typeorm-uml.svg)](https://www.npmjs.com/package/typeorm-uml)
[![License](https://img.shields.io/npm/l/typeorm-uml.svg)](https://github.com/eugene-manuilov/mynewcli/blob/master/package.json)

A command line tool to generate UML diagrams for Typeorm projects. It uses [plantuml](https://plantuml.com/) to render diagrams and outputs an URL to a diagram.

Expand Down Expand Up @@ -59,7 +64,7 @@ ts-node ./node_modules/.bin/typeorm-uml ormconfig.json
typeorm-uml --format=svg --monochrome
```

[![typeorm/typescript-example](http://www.plantuml.com/plantuml/png/bP9DIyD048RFpgyOuoMh5edGImXBWrZinKC9ugriibEpD9iDkrj8AFtl9ltGMgZe76SUtcS6PkAyi7wjAu1hIKjL4tgHLnIs38jAE8Sj9Wc6sVtDT9hsnP3pBxHPKJUGISxRv27dK2f9w3nPChvhoEqRIqMLT01kfUf6MA5HczeKfJMwrzar0S3UYeNmz65iXmmtSBNHv4iZjtYtCw6Io6ASlMPX5B6JSIqqnVYMpfzUqdduE1ups7vdDiRv_-LvvQlpm9CfjJx6xFazExSi3kihSelVBndesGNx0Ja6_CHwuqLJS1lWQCGnY8ATu8_eiGameLeEl_09)](http://www.plantuml.com/plantuml/png/bP9DIyD048RFpgyOuoMh5edGImXBWrZinKC9ugriibEpD9iDkrj8AFtl9ltGMgZe76SUtcS6PkAyi7wjAu1hIKjL4tgHLnIs38jAE8Sj9Wc6sVtDT9hsnP3pBxHPKJUGISxRv27dK2f9w3nPChvhoEqRIqMLT01kfUf6MA5HczeKfJMwrzar0S3UYeNmz65iXmmtSBNHv4iZjtYtCw6Io6ASlMPX5B6JSIqqnVYMpfzUqdduE1ups7vdDiRv_-LvvQlpm9CfjJx6xFazExSi3kihSelVBndesGNx0Ja6_CHwuqLJS1lWQCGnY8ATu8_eiGameLeEl_09)
[![typeorm/typescript-example](http://www.plantuml.com/plantuml/png/XL7DIyCm5B-_l-A9bmOTCc6NKigAEDp5moZYRQJhquOrIKdUeCNkVpVT5rhyo2s_xv2vP-bufsk0gvBUb25ijjH5hS2aIDlahaWl1CkYfe4XmuexR359CCflhnUBB1o1QGfGgPBGCpcot3NaZu0chcpf0VnMcKOwgR4EaOC2hGlS5q9ROpULipeqkXq177jn8vdUhUjGu0SWtXnseYfHnBXypgFfL0JOI4qnlcIhXwTi5TtFPWBsbuZ6UlxR7XvMZ_q1fPPZp1zVyr7O-ZHAaL__l6zGBKSb9-fi-4w7Wb-Jz_raqlU7p7z5vpl0d4mv_F0d)](http://www.plantuml.com/plantuml/png/XL7DIyCm5B-_l-A9bmOTCc6NKigAEDp5moZYRQJhquOrIKdUeCNkVpVT5rhyo2s_xv2vP-bufsk0gvBUb25ijjH5hS2aIDlahaWl1CkYfe4XmuexR359CCflhnUBB1o1QGfGgPBGCpcot3NaZu0chcpf0VnMcKOwgR4EaOC2hGlS5q9ROpULipeqkXq177jn8vdUhUjGu0SWtXnseYfHnBXypgFfL0JOI4qnlcIhXwTi5TtFPWBsbuZ6UlxR7XvMZ_q1fPPZp1zVyr7O-ZHAaL__l6zGBKSb9-fi-4w7Wb-Jz_raqlU7p7z5vpl0d4mv_F0d)

## Contribute

Expand Down
11 changes: 11 additions & 0 deletions examples/shopping-cart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Shopping Cart Database

The Shopping Cart Database in MySQL as the starting point to develop the online shopping cart websites and applications.

## Database Schema

The visual database design of the Shopping Cart Database is shown below:

[![shopping cart example](http://www.plantuml.com/plantuml/png/xLTDRnen4BtxLxZA1TH63QdIIWYXq2Pfa4WgfQkgFKLcFG6BtVNMzX9G4tvxRRDyh6q42abwAITuCtwUZ-UnEPMA25Ma2K9lADon370-WcbjKiUjVdlIUjzlBmsAz1Cm5iWKKrCymQqMhaNl3YukElfJn-qsGaD60Ki50hYQvY3dG0fgoAb4I8vObXD1KfneIkE1kT2sDKFACnuF1K_rZg80XERxubW7UiiKfBYE_o2Ctzf0CQEutiIVkr-xrr7j-AYkBGUvuBI8LPUw1iFXeN9KDF6FpisNoyvDhN5aiLom69huelUj4zKQnmQYJCQyo5GL_LqGMuqc_dxLwVKCwqU3arYniMQ8kjU_3DWmO2o0AA0TpN7MYSwZxjMvHekS1j2OPmhCRj7vpmWzhf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L848JUEdgQ1DO9Vpfn82wGIIg6ifAoAGOUE2cuCh2tngwfxTffbUijZpPQKS1OmRtUqXZjsgL-GkYM3PmUvuN_OJ98T2Tshxqth7nYWosflSAlTrUuaA2s5Tris1eiaXJ8gRpyjhmDB6U8MuZNkH4oo7FzpZFczfj1x1qGCYet54MN50G-yv5I_8wW_4vPg0I99DcmlBiYNBSa77CgQ_5aC9Iw-W8H15Lo9V8rmRxn4mbIAdhP70tBpw2p3zZmInaqO-u8acrnqPrPy7kApAf0dB8yjpEp8gRpwarcd9t-eSbDj0oe86mxfYGwfgauDAaZD84GfQ4R5Z1-wmodkpSWfImnAFG3vf623psxZ9xBAgOJdlCiXZyUq-dBVphy1bKPUIoLLJFMCjPk9YpO3Lp8kMzrlqbaSELxOFjBw4fovnHFDOZami7531WzYtgbiI4sEC3mxA6CbrfNhbST5VkRCZU8qoeVteU_qjy9ualNeVXH_C2xVgzApsM5wRZuE_WlSusBLqww1KXtjNVdCU7myE71wir7otfqJApHrvwpt-ZobFSMUGycikbLTHp2b8iO2DrjFOKAM6B1F05o_f5NbaICAosM0Hi4NiKrm6lvyiwEfLn7Tpgc9PkD-cl29tgwMF-HFy5)

Credits: [https://github.com/tutorials24x7/shopping-cart-database-mysql](https://github.com/tutorials24x7/shopping-cart-database-mysql)
82 changes: 82 additions & 0 deletions examples/shopping-cart/entities/Cart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import {
Column,
Entity,
Index,
JoinColumn,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn
} from 'typeorm';

import { User } from './User';
import { CartItem } from './CartItem';

@Index( 'idx_cart_user', [ 'userId' ], {} )
@Entity( 'cart', { schema: 'shop' } )
export class Cart {

@PrimaryGeneratedColumn( { type: 'bigint', name: 'id' } )
id: string;

@Column( 'bigint', { name: 'userId', nullable: true } )
userId: string | null;

@Column( 'varchar', { name: 'sessionId', length: 100 } )
sessionId: string;

@Column( 'varchar', { name: 'token', length: 100 } )
token: string;

@Column( 'smallint', { name: 'status', default: () => "'0'" } )
status: number;

@Column( 'varchar', { name: 'firstName', nullable: true, length: 50 } )
firstName: string | null;

@Column( 'varchar', { name: 'middleName', nullable: true, length: 50 } )
middleName: string | null;

@Column( 'varchar', { name: 'lastName', nullable: true, length: 50 } )
lastName: string | null;

@Column( 'varchar', { name: 'mobile', nullable: true, length: 15 } )
mobile: string | null;

@Column( 'varchar', { name: 'email', nullable: true, length: 50 } )
email: string | null;

@Column( 'varchar', { name: 'line1', nullable: true, length: 50 } )
line1: string | null;

@Column( 'varchar', { name: 'line2', nullable: true, length: 50 } )
line2: string | null;

@Column( 'varchar', { name: 'city', nullable: true, length: 50 } )
city: string | null;

@Column( 'varchar', { name: 'province', nullable: true, length: 50 } )
province: string | null;

@Column( 'varchar', { name: 'country', nullable: true, length: 50 } )
country: string | null;

@Column( 'datetime', { name: 'createdAt' } )
createdAt: Date;

@Column( 'datetime', { name: 'updatedAt', nullable: true } )
updatedAt: Date | null;

@Column( 'text', { name: 'content', nullable: true } )
content: string | null;

@ManyToOne( () => User, ( user ) => user.carts, {
onDelete: 'RESTRICT',
onUpdate: 'RESTRICT',
} )
@JoinColumn( [ { name: 'userId', referencedColumnName: 'id' } ] )
user: User;

@OneToMany( () => CartItem, ( cartItem ) => cartItem.cart )
cartItems: CartItem[];

}
65 changes: 65 additions & 0 deletions examples/shopping-cart/entities/CartItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {
Column,
Entity,
Index,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn
} from 'typeorm';

import { Cart } from './Cart';
import { Product } from './Product';

@Index( 'idx_cart_item_product', [ 'productId' ], {} )
@Index( 'idx_cart_item_cart', [ 'cartId' ], {} )
@Entity( 'cart_item', { schema: 'shop' } )
export class CartItem {

@PrimaryGeneratedColumn( { type: 'bigint', name: 'id' } )
id: string;

@Column( 'bigint', { name: 'productId' } )
productId: string;

@Column( 'bigint', { name: 'cartId' } )
cartId: string;

@Column( 'varchar', { name: 'sku', length: 100 } )
sku: string;

@Column( 'float', { name: 'price', precision: 12, default: () => "'0'" } )
price: number;

@Column( 'float', { name: 'discount', precision: 12, default: () => "'0'" } )
discount: number;

@Column( 'smallint', { name: 'quantity', default: () => "'0'" } )
quantity: number;

@Column( 'tinyint', { name: 'active', width: 1, default: () => "'0'" } )
active: boolean;

@Column( 'datetime', { name: 'createdAt' } )
createdAt: Date;

@Column( 'datetime', { name: 'updatedAt', nullable: true } )
updatedAt: Date | null;

@Column( 'text', { name: 'content', nullable: true } )
content: string | null;

@ManyToOne( () => Cart, ( cart ) => cart.cartItems, {
onDelete: 'RESTRICT',
onUpdate: 'RESTRICT',
} )
@JoinColumn( [ { name: 'cartId', referencedColumnName: 'id' } ] )
cart: Cart;

@ManyToOne( () => Product, ( product ) => product.cartItems, {
onDelete: 'RESTRICT',
onUpdate: 'RESTRICT',
} )
@JoinColumn( [ { name: 'productId', referencedColumnName: 'id' } ] )
product: Product;

}
56 changes: 56 additions & 0 deletions examples/shopping-cart/entities/Category.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {
Column,
Entity,
Index,
JoinColumn,
JoinTable,
ManyToMany,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn
} from 'typeorm';

import { Product } from './Product';

@Index( 'idx_category_parent', [ 'parentId' ], {} )
@Entity( 'category', { schema: 'shop' } )
export class Category {

@PrimaryGeneratedColumn( { type: 'bigint', name: 'id' } )
id: string;

@Column( 'bigint', { name: 'parentId', nullable: true } )
parentId: string | null;

@Column( 'varchar', { name: 'title', length: 75 } )
title: string;

@Column( 'varchar', { name: 'metaTitle', nullable: true, length: 100 } )
metaTitle: string | null;

@Column( 'varchar', { name: 'slug', length: 100 } )
slug: string;

@Column( 'text', { name: 'content', nullable: true } )
content: string | null;

@ManyToOne( () => Category, ( category ) => category.categories, {
onDelete: 'RESTRICT',
onUpdate: 'RESTRICT',
} )
@JoinColumn( [ { name: 'parentId', referencedColumnName: 'id' } ] )
parent: Category;

@OneToMany( () => Category, ( category ) => category.parent )
categories: Category[];

@ManyToMany( () => Product, ( product ) => product.categories )
@JoinTable( {
name: 'product_category',
joinColumns: [ { name: 'categoryId', referencedColumnName: 'id' } ],
inverseJoinColumns: [ { name: 'productId', referencedColumnName: 'id' } ],
schema: 'shop',
} )
products: Product[];

}
Loading

0 comments on commit 9e7fcc3

Please sign in to comment.