Up and zonk
Generate code from a JSON models to quickly stand up an Angular UI.
For MySQL JSON table models:
- TypeORM entities https://github.com/typeorm/typeorm for ts.ed framework (https://tsed.io/)
- TypeScrip interface
- Angular service
- Place holders for action, list, details, edit Angular components
Next:
- Angular Material list, details, edit/create templates
- support for enhanced models
- bug fixes for current templates
- extending testing
Known issues:
- sometimes throws exception if base out folder does not exists, but finishes correctly.
- excludes must be specified, not optional, geez.
... zzz ...
python3 -m venv {workspaceDir}/.env source {workspaceDir}.env/bin/activate pip install -r requirements.txt
Install Python3 (3.8)
Add pystache module (https://github.com/defunkt/pystache) Add inflect module
pip install yaml
pip install inflect
pip install pystache
pystache-testExample:
python3 ./src/genie.py productMain configuration file to locate meta-model, specify templates base folder and output base folder.
up-zonk.yaml
A sample meta-model configuration:
.models/product.yaml
A sample original MySQL models:
models/original/product.json
A sample of enhanced model (coming soon):
models/enhanced/product.json
Recommended extensions for VS Code;
https://github.com/Microsoft/vscode-python
https://github.com/dnwhte/vscode-mustache-syntax-highlighting
https://github.com/MicrosoftDocs/intellicode
make sure you have Python3 correctly configured on Mac, see the docs.
Using nodemon to watch _.ts, _.mustache, _.yaml and _.json files and restart python3 if changes detected. Speeds up development.
Install nodejs
Install nodemon
npm install nodemon -gRun nodemon
nodemon --exec "python3 ./src/genie.py product" --ext py,mustache,yaml,jsonor run a script
zsh start.zshA test app is an Angular 9 + Angular Material 9 web app. It runs on a nodejs server. The server uses Ts.ED project (https://tsed.io/).
./tests/catalog
- Create 'catalog'
- Run tests/catalog/database/seed.sql script
It will create 'product' table with two records in it.
open a terminal window
Server
cd ./tests/catalog/server
npm install
npm startopen another terminal window
Client
cd tests/catalog/client
npm install
npm startOpen browser
http://localhost:8080/dashboard
Get Docker up and running
docker pull mysql
docker run --name mysql1 -e MYSQL_ROOT_HOST=% -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pass -d mysql:latest-
Execute in MySQLWorkbench
select * from information_schema.columns where table_schema = 'catalog' and table_name = 'product' order by table_name,ordinal_position
Note: SHOW COLUMNS FROM tbl_name can also be used, however, it lucks details and will need additional parsing effort.
-
Save result to product.json
-
Place product.json to models/original