1 | # CUBA Platform front-end and TypeScript SDK generator
|
2 |
|
3 | The generator is `@cuba-platform/front-generator` npm package which
|
4 | * provides an ability to generate:
|
5 | * [Polymer 2 starter](https://doc.cuba-platform.com/manual-7.0/polymer_ui.html)
|
6 | * [React starter](src/generators/react-typescript/app/template/README.md)
|
7 | * [Framework agnostic TS SDK](src/generators/sdk/README.md)
|
8 | * is used by [CUBA Studio](https://doc.cuba-platform.com/studio/) for [front module](https://doc.cuba-platform.com/manual-7.0/front_ui.html) creation
|
9 |
|
10 | ## Using via command line
|
11 |
|
12 | ### Prerequisites
|
13 |
|
14 | Install [Node.js](https://nodejs.org/en/download/) 10.15+ and npm 6+ (usually comes with node). Install [CUBA Studio](https://doc.cuba-platform.com/studio/#installation).
|
15 |
|
16 | Install the generator using the npm package manager:
|
17 |
|
18 | ```bash
|
19 | npm install -g @cuba-platform/front-generator
|
20 | ```
|
21 |
|
22 | Then you will be able to run it via command line:
|
23 |
|
24 | ```bash
|
25 | gen-cuba-front
|
26 | ```
|
27 |
|
28 | Alternatively you can also run the generator without installation using `npx`:
|
29 |
|
30 | ```bash
|
31 | npx @cuba-platform/front-generator
|
32 | ```
|
33 |
|
34 | ### Workflow
|
35 |
|
36 | In order to create some project-related stuff we need to pass project information to the generator. There are two types of ways of doing it
|
37 |
|
38 | #### Interactive
|
39 |
|
40 | Open your project in Intellij/CUBA Studio. Open settings (`File > Settings`), then open `Languages & Frameworks > CUBA` . Tick the `Old Studio integration` checkbox:
|
41 |
|
42 | ![GitHub Logo](etc/studio-integration.png)
|
43 |
|
44 | After that when running generator without any options it will automatically detect CUBA projects opened in Studio:
|
45 |
|
46 | ```bash
|
47 | gen-cuba-front sdk:all
|
48 | ```
|
49 | ![Interactive project selection](etc/interactive-projects.png)
|
50 |
|
51 | #### Manual
|
52 |
|
53 | Alternatively you can export project model manually. In main menu select `CUBA > Advanced > Export project model`. Studio will generate `projectModel.json` file.
|
54 |
|
55 | Use `--model` cli option to specify destination to project model file:
|
56 |
|
57 | ```bash
|
58 | gen-cuba-front sdk:all --model /work/cuba-samples/sample-sales/projectModel.json
|
59 | ```
|
60 |
|
61 |
|
62 | ### CLI Options
|
63 | * `-v, --version`: prints current version of the generator.
|
64 | * `-h, --help`: prints help for given command.
|
65 |
|
66 | #### Common generation options
|
67 |
|
68 | * `--model`: path to exported project model.
|
69 | * `--dest`: destination directory (default: current).
|
70 |
|
71 |
|
72 | ## Development
|
73 | Run locally
|
74 | ```bash
|
75 | npm run watch
|
76 | npx gen-cuba-front
|
77 | ```
|
78 |
|
79 | ## Testing
|
80 | ```bash
|
81 | npm test
|
82 | ```
|
83 |
|
84 | ## Integration tests
|
85 | Integration tests are used compiled version of front-generator. To apply your code changes you need to run ```npm run compile``` before testing.
|
86 | <br>
|
87 | Apps and sdk generated in ```./tmp``` directory.
|
88 | ### Run all
|
89 | ```bash
|
90 | npm run test:e2e
|
91 | ```
|
92 |
|
93 | ### SDK generation
|
94 | ```bash
|
95 | npm run test:e2e:sdk
|
96 | ```
|