nuxeo/generator-nuxeo-meta

Name: generator-nuxeo-meta

Owner: Nuxeo

Description: null

Created: 2016-01-26 14:23:08.0

Updated: 2018-05-14 15:59:36.0

Pushed: 2018-05-14 17:44:15.0

Homepage: null

Size: 718

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Generator Nuxeo Metamodel

Build Status devDependency Status

Introduction

This project is the metamodel used by the nuxeo/generator-nuxeo project, a Yeoman generator for Nuxeo. It defines what can be generated with the generator using a simple description format.

Format description

Each folder is a generator; you can pass several generator names to the yo nuxeo command.

A basic field explanation can be found on the descriptor sample file.

Descriptor dependency, ordering, skip
Using the Generator Inheritance

The descriptor file is handled using the require node module; you need to use module.exports to export your descriptor in a descriptor.js file.

A descriptor can depend from another one. For instance, an operation generator depends on the default generator, which checks if a project initialization is needed. The default value is default.

le.exports = {
pends: 'default'

Using Skip and Ensure Fields

Sometimes, you can't use a generator because the target project is not suitable, or you do not want to generate something twice. You have two ways to do that:

For instance, the single-module generator is skipped when there is already a pom.xml file.

le.exports = {
ip: function() {
return this.fs.exists('pom.xml');

.

For instance, the package generator can't be executed on a single module project:

le.exports = {
sure: function() {
return this.config['multi'];

.

Using type Field

The type field is useful when you are in a multi-module archetype. As the main module is a pom; you can chose in which submodule you'd like to force the generation. If you do not use the type field, user can set it using the --type option on the generator. The default value is core. The submodule is automatically added to the parent pom.xml file if needed.

le.exports = {
pe: 'core',
.

Configuration

Storing project configuration can be done using the config field; and can be read later to skip some generator; or having a default value for a parameter… And you'll be able to read them using this.config.read('mykey').

le.exports = {
nfig: {
multi: true
    
.

Parameters

The params field defines which parameters are prompted to the user. Prompting is handled by Inquirer.js, you can read their documentation to have a full explanation of each type.

To sum up:


e: 'input',
e: 'package',
sage: 'Operation package:',
re: true,
idate: function(value) {
eturn value.split('.').length === 0 ? '' : true;

ter: function(answer) {
eturn answer.replace(/\s+/g, '.');


Java classes

Define main or test Java classes to be generated to a java-main, or java-test field. For both, each entry is an object with a src and a dest entries. The src value should refer to a local file in the classes folder; and dest only to the expected filename. The package is handled automatically from the package parameter of your generator. The when function is not mandatory, it makes possible to skip some classes generation depending of the answers values.

le.exports = {
ain-java': [{
src: "operation.java",
dest: "{{s.camelize(operation_name)}}.java",
when: function(answers) {
  return true;
}
,
est-java': [{
src: "test.java",
dest: "Test{{s.camelize(operation_name)}}.java",
when: function(answers) {
  return true;
}
,

Templates

All files/folders present in the templates folder are rendered with a simple rendering engine with parameters in its context. To template in a file path, escape it using {{param}}.

In the templating context, you have access to underscore.string to have some useful methods.

Other templates' plain files are using ejs to be rendered; with also underscore.string exposed in the s variable.

/main/java/{{s.unpackagize(package)}}/.empty
 = {
ackage: 'org.nuxeo.readme'

l create a folder: src/main/java/org/nuxeo/readme

You can also ignore some files during the templating symtem. To do that, add a templates-ignore containing an array of regex that matches the ignored files.

plates-ignore': [/\.html$/, /.+xx.+/],
Contributions

Contributions are handled a similar way than java classes;

ributions: [{
c: "operation.xml",
st: "{{s.dasherize(s.decapitalize(operation_name))}}-operation-contrib.xml"

Dependencies

Adding dependencies to the target pom.xml file. A dependency is described with its GAV: <groupId>:<artifactId>[:<version>[:<extension>[:<classifier>]]].

It also allows to add all 'parent child modules' as project dependencies, useful for the Package project's pom.xml.

ndencies: [
rg.nuxeo.ecm.automation:nuxeo-automation-core",
rg.nuxeo.ecm.automation:nuxeo-automation-test:::test"


ndencies: 'inherited'
Post Installation Commands

Post installation commands are run inside the corresponding module folder in case of a multi-module project. Useful to install npm or bower dependencies at install time.

all: [{
d: 'npm', // The command to spawn.
gs: ['arg1', 'arg2'], // Arguments passed to the command without any modification.
ts: {
something: true,
default: 'value'
// And command options if needed. Check https://www.npmjs.com/package/dargs to understand the conversion logic.

Licensing

Apache License, Version 2.0

About Nuxeo

Nuxeo dramatically improves how content-based applications are built, managed and deployed, making customers more agile, innovative and successful. Nuxeo provides a next generation, enterprise ready platform for building traditional and cutting-edge content oriented applications. Combining a powerful application development environment with SaaS-based tools and a modular architecture, the Nuxeo Platform and Products provide clear business value to some of the most recognizable brands including Verizon, Electronic Arts, Sharp, FICO, the U.S. Navy, and Boeing. Nuxeo is headquartered in New York and Paris. More information is available at www.nuxeo.com.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.