Skip to content

Commit

Permalink
updates info about component generator after octane release
Browse files Browse the repository at this point in the history
  • Loading branch information
gokatz committed Oct 3, 2019
1 parent 50efb43 commit 08c4ac2
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions guides/basic-use/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,51 @@ ember generate <type-of-file> <name-of-your-choice>

### What it does

`ember generate` creates new files within your app. For example, you can use it to create components, routes, services, models, and more. For a full list, type `ember generate --help`.
`ember generate` creates new files within your app. For example, you can use it to create components, routes, services, models, and more.

For a full list, type **`ember generate --help`.**

The CLI's `generate` command will ensure that new files contain the necessary boilerplate, that they go in the right directories, and that file naming conventions are followed. For example, components must always have a dash in their names.
To avoid mistakes that are hard to debug, always use the CLI to create files instead of creating the files by hand.

### Example use
### Example Use: Component Generators

This command will make a component named `packing-list`. It will create three files in the app:
**Before Octane (< v3.14):**

* `packing-list.hbs`, which defines what it looks like
This command will make a component named `packing-list`. It will create the following files in the app:

* `packing-list.hbs`, which defines what it looks like (view layer)
* `packing-list.js` with JavaScript code to handle user interaction
* `packing-list-test.js` with an integration test (aka rendering test)

command:
```shell
ember generate component packing-list
```

_Note:_
1. The generated component's JavaScript files will be a classic Ember component extending from the `@ember/component` base class.

**After Octane (>= v3.14):**

The above mentioned command will create only the `packing-list.hbs` and `packing-list-test.js` file and **not the backing JavaScript file.**

If we want to manage internal component state or respond to user interactions etc., then we can create a JavaScript file separately
that backs up the view layer (`packing-list.hbs`) using the following command:

```shell
ember generate component-class packing-list
```

This command will create a `packing-list.js` file under `/components` directory.

_Note:_

1. The generated component's JavaScript files will be a Glimmer component by default extending from the `@glimmer/component` base class.
2. Classic component can be generated by passing an extra flag: `--component-class=@ember/component`
3. Template-Only component can be generated by passing the flag: `--component-class=@ember/component/template-only`
4. The template file (`packing-list.hbs`) will also be created under `/components` directory instead of `/templates/components` directory as per the [Component template co-location RFC](https://github.com/emberjs/rfcs/blob/master/text/0481-component-templates-co-location.md)

### Learn more

- [Ember Quickstart Guide](https://guides.emberjs.com/release/getting-started/quick-start/#toc_define-a-route) for creating a route
Expand All @@ -133,7 +161,7 @@ ember install <addon-name>

### What it does

`ember install` is used to install addons within your app. An addon is an npm package that was built specifically for use in an Ember app. You can find a full list of addons on [Ember Observer](https://emberobserver.com). There are addon versions of many popular npm libraries, as well as packages that are unique to Ember. The majority are open source community addons.
`ember install` is used to install addons within your app. An addon is an npm package that was built specifically for use in an Ember app. You can find a full list of addons on [Ember Observer](https://emberobserver.com). There are addon versions of many popular npm libraries, as well as packages that are unique to Ember. The majority are open source community addons.
By convention, most addons have `ember` in the name, but not all of them.

To use non-addon npm packages directly, see "Managing Dependencies" section of the [Ember.js Guide](https://guides.emberjs.com/release/addons-and-dependencies/managing-dependencies/)
Expand Down

0 comments on commit 08c4ac2

Please sign in to comment.