|
| 1 | +# Yeoman Resources |
| 2 | + |
| 3 | +## What is Yeoman? |
| 4 | +“...a generic scaffolding system allowing the creation of any kind of app. It allows for rapidly getting started on new projects and streamlines the maintenance of existing projects.” |
| 5 | + |
| 6 | +* Provides an app-agnostic generator ecosystem that can be used to put together entire projects or just parts |
| 7 | +* Based in node.js using the npm package manager |
| 8 | +* Generators are available for Angular, Backbone, React, Polymer, and nearly 6,000 other projects |
| 9 | + |
| 10 | +Common use cases for Yeoman generators include: |
| 11 | + |
| 12 | +* Create a project |
| 13 | +* Create a new chunk of a project, like a unit test |
| 14 | +* Create a module or package |
| 15 | +* Bootstrap a new service |
| 16 | +* Enforce standards, best practices, and style guides in generated code |
| 17 | +* Gets users started quickly with sample apps |
| 18 | + |
| 19 | +It’s very easy to install once you have NPM on a system: |
| 20 | + |
| 21 | +* Install it: npm install -g yo (-g only works with admin privileges or via sudo if allowed) |
| 22 | +* Find your generator and install it: npm install -g generator-webapp (see above comment!) |
| 23 | +* And run it: yo webapp |
| 24 | + |
| 25 | +## What are some basic Yeoman resources to get started? |
| 26 | +There are quite a few: |
| 27 | + |
| 28 | +* Main Yeoman site: http://yeoman.io/ |
| 29 | +* Writing your own Generator: http://yeoman.io/authoring/index.html |
| 30 | +* Good tutorial: https://scotch.io/tutorials/create-a-custom-yeoman-generator-in-4-easy-steps |
| 31 | +* IntelliJ Yeoman Plug-in: https://plugins.jetbrains.com/plugin/7987-yeoman |
| 32 | +* VSCode yo-code Generator: https://code.visualstudio.com/docs/extensions/yocode |
| 33 | +* Example from rsvalerio - Apache Camel + Spring Boot + Docker + Release plugin Yeoman Generator: https://github.com/rsvalerio/generator-camel |
| 34 | + |
| 35 | +## Why should we care? |
| 36 | +Yeoman can integrate easily with many of the IDEs we currently want to support: |
| 37 | + |
| 38 | +* VSCode (see https://code.visualstudio.com/docs/extensions/yocode ) |
| 39 | +* IntelliJ (with a plug-in installed) - https://plugins.jetbrains.com/plugin/7987-yeoman |
| 40 | +* Eclipse Che |
| 41 | + |
| 42 | +Depending on what we want to achieve regarding Fuse, we can quickly deliver yeoman generators to the http://yeoman.io/generators/ registry and have new functionality available to our users fast. |
| 43 | + |
| 44 | +## What are we doing in Yeoman? |
| 45 | +In Spring 2018, we started playing with Yeoman locally as a quick win to generate a simple project in a cross-platform manner with little code. We demonstrated it at the F2F in Italy in June 2018 and continued work on the Camel Project generator from there. |
| 46 | + |
| 47 | +A few notes about the generator: |
| 48 | + |
| 49 | +* After installing the generator, create a new directory, change to the directory, and run: yo camel-project |
| 50 | +* You provide a name (it defaults to the folder name), a version (defaults to 2.18.2), your DSL type (spring, blueprint, or java - defaults to spring), and a package name (defaults to "com." + project name). |
| 51 | +* If all is well, it creates a simple project based on the DSL-flavored template you provided. |
| 52 | +* To build and run the project, type "mvn install" and "mvn camel:run". |
| 53 | + |
| 54 | +### Running from command line without prompts |
| 55 | +With version 0.1.2 we have added command-line capabilities for providing argument values for the prompted information. Without prompting, this allows us to use the generator as part of a larger script to help prep a new project in a more automated fashion. |
| 56 | + |
| 57 | +This allows us to do things like the following and avoid having to go through the prompts: |
| 58 | +``` |
| 59 | +> yo camel-project appname=MyApp camelVersion=2.22.2 camelDSL=spring package=com.myapp |
| 60 | +``` |
| 61 | + |
| 62 | +## What are some important links for the Camel Project generator? |
| 63 | + |
| 64 | +* Camel Project generator is available at: https://www.npmjs.com/package/generator-camel-project |
| 65 | +* Code is available at: https://github.com/camel-tooling/generator-camel-project |
| 66 | +* Current list of issues: https://github.com/camel-tooling/generator-camel-project/issues |
| 67 | +* Sonar - https://sonarcloud.io/dashboard?id=generator-camel-project |
| 68 | +* Travis - https://travis-ci.org/camel-tooling/generator-camel-project |
| 69 | + |
| 70 | +## Development Notes |
| 71 | + |
| 72 | +### Grabbing the code |
| 73 | +The code is available at github currently in: https://github.com/camel-tooling/generator-camel-project/ |
| 74 | + |
| 75 | +Fork the project and clone it locally. If you have suggestions or improvements, feel free to create |
| 76 | +pull requests and issues. |
| 77 | + |
| 78 | +### Running the generator |
| 79 | +From the main generator-camel-project directory: |
| 80 | +``` |
| 81 | +> npm link |
| 82 | +``` |
| 83 | + |
| 84 | +Then create a directory you wish to create a Camel project in and run the generator as described above: |
| 85 | +``` |
| 86 | +> yo camel-project |
| 87 | +``` |
| 88 | + |
| 89 | +Read more [here](./README.md) for details on how to run the generator with all the bells and whistles. |
| 90 | + |
| 91 | +### Running the Mocha tests |
| 92 | +First you must install mocha with npm. |
| 93 | + |
| 94 | +``` |
| 95 | +> npm install --global mocha |
| 96 | +``` |
| 97 | + |
| 98 | +Then, in the main generator-camel-project directory: |
| 99 | +``` |
| 100 | +> mocha --timeout=5000 |
| 101 | +``` |
| 102 | + |
| 103 | +Or you can run: |
| 104 | +``` |
| 105 | +> npm test |
| 106 | +``` |
| 107 | + |
| 108 | +This fires up a mocha instance with the timeout set. |
| 109 | + |
| 110 | +### Deploying to NPM |
| 111 | +Currently we've set up an automated system with Travis that uploads a new version to NPM when the following conditions are met: |
| 112 | + |
| 113 | +* Version has been updated (https://github.com/camel-tooling/generator-camel-project/blob/master/package.json#L3) |
| 114 | +* A tag has been created (https://github.com/camel-tooling/generator-camel-project/tags) |
| 115 | + |
| 116 | +When those conditions are met, the project is uploaded to the npm server and presented to our users. |
| 117 | + |
| 118 | +The NPM account currently used is for Brian Fitzpatrick (https://www.npmjs.com/settings/bfitzpatrh/) and reuses a token generated there. |
| 119 | + |
0 commit comments