UNPKG

2.7 kBMarkdownView Raw
1# CUBA Platform front-end and TypeScript SDK generator
2
3The 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
14Install [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
16Install the generator using the npm package manager:
17
18```bash
19npm install -g @cuba-platform/front-generator
20```
21
22Then you will be able to run it via command line:
23
24```bash
25gen-cuba-front
26```
27
28Alternatively you can also run the generator without installation using `npx`:
29
30```bash
31npx @cuba-platform/front-generator
32```
33
34### Workflow
35
36In 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
40Open 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
44After that when running generator without any options it will automatically detect CUBA projects opened in Studio:
45
46```bash
47gen-cuba-front sdk:all
48```
49![Interactive project selection](etc/interactive-projects.png)
50
51#### Manual
52
53Alternatively you can export project model manually. In main menu select `CUBA > Advanced > Export project model`. Studio will generate `projectModel.json` file.
54
55Use `--model` cli option to specify destination to project model file:
56
57```bash
58gen-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
73Run locally
74```bash
75npm run watch
76npx gen-cuba-front
77```
78
79## Testing
80```bash
81npm test
82```
83
84## Integration tests
85Integration tests are used compiled version of front-generator. To apply your code changes you need to run ```npm run compile``` before testing.
86<br>
87Apps and sdk generated in ```./tmp``` directory.
88### Run all
89```bash
90npm run test:e2e
91```
92
93### SDK generation
94```bash
95npm run test:e2e:sdk
96```