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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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.
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.
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'
Skip
and Ensure
FieldsSometimes, 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:
skip
method; useful when you do not want to generate it several times. The skip
value is a function
where this
is the generator.ensure
method; useful when you'd stop the generation due to some context issues. The skip
value is a function
where this
is the generator.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'];
.
type
FieldThe 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',
.
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
.
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, '.');
type
: is the type of the input input
, checkbox
,…name
: variable namemessage
: message displayed to help the user answeringvalidate
: function to ensure the user input is rightfilter
: function called after the user input finished to change itDefine 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;
}
,
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 are handled a similar way than java classes;
ributions: [{
c: "operation.xml",
st: "{{s.dasherize(s.decapitalize(operation_name))}}-operation-contrib.xml"
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 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.
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.