Skip to content
Generator and maintainable scripts for CUBA Platform front-end clients
TypeScript HTML JavaScript CSS
Branch: master
Clone or download
vyacheslav-pushkin DataTable: defaultSort has no effect [cuba-platform/cuba-react#23]
defaultSort prop is removed.
Default sorting is now determined by dataCollection.sort.
Latest commit 548bcb5 Nov 6, 2019

README.md

CUBA Platform front-end and TypeScript SDK generator

Build Status

The generator is @cuba-platform/front-generator npm package which

Using via command line

Prerequisites

Install Node.js 10.15+ and npm 6+ (usually comes with node). Install CUBA Studio.

Install the generator using the npm package manager:

npm install -g @cuba-platform/front-generator

Then you will be able to run it via command line:

gen-cuba-front

Alternatively you can also run the generator without installation using npx:

npx @cuba-platform/front-generator

Workflow

In order to create some project-related stuff we need to pass project information to the generator. There are two approaches:

Interactive

Open your project in CUBA Studio (Intellij-based). Open settings (File > Settings), then open Languages & Frameworks > CUBA . Tick the Old Studio integration checkbox:

GitHub Logo

After that when running generator without any options it will automatically detect CUBA projects opened in Studio:

gen-cuba-front sdk:all

Interactive project selection

Manual

Alternatively you can export project model manually. In main menu select CUBA > Advanced > Export project model. Studio will generate projectModel.json file.

Use --model cli option to specify destination to project model file:

gen-cuba-front sdk:all --model /work/cuba-samples/sample-sales/projectModel.json

CLI Options

  • -v, --version: prints current version of the generator.
  • -h, --help: prints help for given command.

Common generation options

  • --model: path to exported project model.
  • --dest: destination directory (default: current).

Development

Run locally

npm run watch
npx gen-cuba-front

###Code Generation Templates We are using template folder inside generator to create templates from which the code will be generated. Templates processed via EJS.
Template files could be any type, but for increase code readability for complex files there is ability to add .ejs suffix to template name. During file processing suffix will be removed. This mean files EntityManagementEditor.tsx.ejs and EntityManagementEditor.tsx both will be processed to file EntityManagementEditor.tsx and the only on different is how it will be highlighted in IDE.

Testing

Test folders

/fixtures - initial data required for tests
/generated - result of generators work - apps and sdk will be stored here
/expected - files gauges used for comparison with generated code

Run tests

npm test

Integration tests

Integration tests are used compiled version of front-generator. To apply your code changes you need to run npm run build before testing.
Apps and sdk generated in ./test/e2e/generated directory.

Run all e2e tests

npm run test:e2e

Generators e2e tests

SDK

npm run test:e2e:sdk

React client

npm run test:e2e:react

Polymer 2

test:e2e:polymer2

Polymer 2 typescript

test:e2e:polymer2-ts
You can’t perform that action at this time.