Skip to content

Commit 45264aa

Browse files
authored
Merge pull request #2000 from ember-learn/fix-tutorial
Fix tutorial
2 parents 3d1f3c3 + 1622395 commit 45264aa

File tree

142 files changed

+1042
-834
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+1042
-834
lines changed

guides/v4.10.0/tutorial/part-1/automated-testing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Once we are done patting ourselves on the back, go ahead and run the following c
3333
$ ember generate acceptance-test super-rentals
3434
installing acceptance-test
3535
create tests/acceptance/super-rentals-test.js
36+
37+
Running "lint:fix" script...
3638
```
3739

3840
This is called a _[generator](https://cli.emberjs.com/release/basic-use/cli-commands/#generatemorefiles)_ command in Ember CLI. Generators automatically create files for us based on Ember's conventions and populate them with the appropriate boilerplate content, similar to how `ember new` initially created a skeleton app for us. It typically follows the pattern `ember generate <type> <name>`, where `<type>` is the kind of thing we are generating, and `<name>` is what we want to call it.

guides/v4.10.0/tutorial/part-1/building-pages.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
In this chapter, you will build the first few pages of your Ember app and set up links between them. By the end of this chapter, you should have two new pages – an about page and a contact page. These pages will be linked to from your landing page:
44

5-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (homepage) by the end of the chapter" width="1024" height="250">
5+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (homepage) by the end of the chapter" width="1024" height="251">
66

7-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (about page) by the end of the chapter" width="1024" height="274">
7+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (about page) by the end of the chapter" width="1024" height="275">
88

9-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (contact page) by the end of the chapter" width="1024" height="444">
9+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="The Super Rentals app (contact page) by the end of the chapter" width="1024" height="445">
1010

1111
While building these pages, you will learn about:
1212

@@ -112,7 +112,7 @@ Ember comes with strong _conventions_ and sensible defaults—if we were startin
112112

113113
Once you have added the route and the template above, we should have the new page available to us at `http://localhost:4200/getting-in-touch`.
114114

115-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Contact page" width="1024" height="394">
115+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Contact page" width="1024" height="395">
116116

117117
## Linking Pages with the `<LinkTo>` Component
118118

@@ -181,11 +181,11 @@ However, when clicking on one of these special links, Ember will intercept the c
181181

182182
<!-- TODO: make this a gif instead -->
183183

184-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Index page after adding the link" width="1024" height="250">
184+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Index page after adding the link" width="1024" height="251">
185185

186-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="About page after adding the link" width="1024" height="274">
186+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="About page after adding the link" width="1024" height="275">
187187

188-
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Contact page after adding the link" width="1024" height="444">
188+
<img src="/images/tutorial/part-1/building-pages/[email protected]" alt="Contact page after adding the link" width="1024" height="445">
189189

190190
We will learn more about how all of this works soon. In the meantime, go ahead and click on the link in the browser. Did you notice how snappy that was?
191191

guides/v4.10.0/tutorial/part-1/component-basics.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
In this chapter, you will _[refactor](../../../components/introducing-components/#toc_breaking-it-into-pieces)_ your existing templates to use components. We will also be adding a site-wide navigation bar:
44

5-
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="The Super Rentals app by the end of the chapter" width="1024" height="314">
5+
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="The Super Rentals app by the end of the chapter" width="1024" height="315">
66

77
In doing so, you will learn about:
88

@@ -73,7 +73,7 @@ Let's try it out by editing the index template:
7373
7474
After saving the changes, your page should automatically reload, and, _voilà_... nothing changed? Well, that's exactly what we wanted to happen this time! We successfully _[refactored](../../../components/introducing-components/#toc_breaking-components-down-further)_ our index template to use the `<Jumbo>` component, and everything still works as expected. And the tests still pass!
7575

76-
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Index page – nothing changed" width="1024" height="250">
76+
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Index page – nothing changed" width="1024" height="251">
7777

7878
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Tests still passing after the refactor" width="1024" height="512">
7979

@@ -119,9 +119,9 @@ Let's do the same for our other two pages as well.
119119
120120
After saving, everything should look exactly the same as before, and all the tests should still pass. Very nice!
121121
122-
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="About page – nothing changed" width="1024" height="274">
122+
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="About page – nothing changed" width="1024" height="275">
123123
124-
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Contact page – nothing changed" width="1024" height="444">
124+
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Contact page – nothing changed" width="1024" height="445">
125125
126126
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Tests still passing another round of refactor" width="1024" height="512">
127127
@@ -135,6 +135,8 @@ Before we move on to the next component, let's write an automated test for our `
135135
$ ember generate component-test jumbo
136136
installing component-test
137137
create tests/integration/components/jumbo-test.js
138+
139+
Running "lint:fix" script...
138140
```
139141

140142
Here, we used the generator to generate a _[component test](../../../testing/testing-components/)_, also known as a rendering test. These are used to render and test a single component at a time. This is in contrast to the acceptance tests that we wrote earlier, which have to navigate and render entire pages worth of content.
@@ -248,7 +250,7 @@ Next, we will add our `<NavBar>` component to the top of each page:
248250

249251
Voilà, we made another component!
250252

251-
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Index page with nav" width="1024" height="314">
253+
<img src="/images/tutorial/part-1/component-basics/[email protected]" alt="Index page with nav" width="1024" height="315">
252254

253255
<div class="cta">
254256
<div class="cta-note">

guides/v4.10.0/tutorial/part-1/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Welcome to the Ember Tutorial!
44

55
In this tutorial, we will use Ember to build an application called Super Rentals. This will be a website for browsing interesting places to stay during your next vacation. Check out the [finished app](https://ember-super-rentals.netlify.com) to get a sense of the scope of the project.
66

7-
<img src="/images/tutorial/part-2/provider-components/[email protected]" alt="The finished Super Rentals app" width="1024" height="1327">
7+
<img src="/images/tutorial/part-2/provider-components/[email protected]" alt="The finished Super Rentals app" width="1024" height="1328">
88

99
Along the way, you will learn everything you need to know to build a basic Ember application. If you get stuck at any point during the tutorial, feel free to download <https://github.com/ember-learn/super-rentals/tree/super-rentals-tutorial-output> for a complete working example.
1010

guides/v4.10.0/tutorial/part-1/interactive-components.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ In this chapter, you will add interactivity to the page, allowing the user to cl
44

55
<!-- TODO: make this a gif instead -->
66

7-
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="The Super Rentals app by the end of the chapter (default image size)" width="1024" height="1129">
7+
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="The Super Rentals app by the end of the chapter (default image size)" width="1024" height="1130">
88

99
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="The Super Rentals app by the end of the chapter (large image size)" width="1024" height="1500">
1010

@@ -34,6 +34,8 @@ Ember optionally allows us to associate JavaScript code with a component for exa
3434
$ ember generate component-class rental/image
3535
installing component-class
3636
create app/components/rental/image.js
37+
38+
Running "lint:fix" script...
3739
```
3840

3941
This generated a JavaScript file with the same name as our component's template at `app/components/rental/image.js`. It contains a _[JavaScript class](https://javascript.info/class)_, _[inheriting](https://javascript.info/class-inheritance)_ from `@glimmer/component`.
@@ -199,7 +201,7 @@ With that, we have created our first _interactive_ component. Go ahead and try i
199201

200202
<!-- TODO: make this a gif instead -->
201203

202-
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="&lt;Rental::Image&gt; (default size)" width="1024" height="1129">
204+
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="&lt;Rental::Image&gt; (default size)" width="1024" height="1130">
203205

204206
<img src="/images/tutorial/part-1/interactive-components/[email protected]" alt="&lt;Rental::Image&gt; (large size)" width="1024" height="1500">
205207

guides/v4.10.0/tutorial/part-1/more-about-components.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
It's time to finally work on the rentals listing:
44

5-
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="The Super Rentals app by the end of the chapter" width="1024" height="1129">
5+
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="The Super Rentals app by the end of the chapter" width="1024" height="1130">
66

77
While building this list of rental properties, you will learn about:
88

@@ -23,6 +23,8 @@ installing component
2323
tip to add a class, run `ember generate component-class rental`
2424
installing component-test
2525
create tests/integration/components/rental-test.js
26+
27+
Running "lint:fix" script...
2628
```
2729

2830
The generator created two new files for us, a component template at `app/components/rental.hbs`, and a component test file at `tests/integration/components/rental-test.js`.
@@ -112,7 +114,7 @@ Finally, let's invoke this a couple of times from our index template to populate
112114
113115
With that, we should see the `<Rental>` component showing our Grand Old Mansion three times on the page:
114116
115-
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="Three Grand Old Mansions" width="1024" height="1129">
117+
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="Three Grand Old Mansions" width="1024" height="1130">
116118
117119
Things are looking pretty convincing already; not bad for just a little bit of work!
118120
@@ -128,6 +130,8 @@ installing component
128130
tip to add a class, run `ember generate component-class rental/image`
129131
installing component-test
130132
create tests/integration/components/rental/image-test.js
133+
134+
Running "lint:fix" script...
131135
```
132136

133137
This time, we had a `/` in the component's name. This resulted in the component being created at `app/components/rental/image.hbs`, which can be invoked as `<Rental::Image>`.
@@ -173,7 +177,7 @@ Instead of hard-coding specific values for the `src` and `alt` attributes on the
173177
174178
We specified a `src` and an `alt` HTML attribute here, which will be passed along to the component and attached to the element where `...attributes` is applied in the component template. You can think of this as being similar to `{{yield}}`, but for HTML attributes specifically, rather than displayed content. In fact, we have already used this feature [earlier](../building-pages/) when we passed a `class` attribute to `<LinkTo>`.
175179
176-
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="The &lt;Rental::Image&gt; component in action" width="1024" height="1129">
180+
<img src="/images/tutorial/part-1/more-about-components/[email protected]" alt="The &lt;Rental::Image&gt; component in action" width="1024" height="1130">
177181
178182
This way, our `<Rental::Image>` component is not coupled to any specific rental property on the site. Of course, the hard-coding problem still exists (we simply moved it to the `<Rental>` component), but we will deal with that soon. We will limit all the hard-coding to the `<Rental>` component, so that we will have an easier time cleaning it up when we switch to fetching real data.
179183

guides/v4.10.0/tutorial/part-1/orientation.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To verify that your installation was successful, run:
2424

2525
```shell
2626
$ ember --version
27-
ember-cli: 4.5.0
27+
ember-cli: 4.10.0
2828
node: 14.19.1
2929
os: linux x64
3030
```
@@ -38,7 +38,7 @@ We can create a new project using Ember CLI's `new` command. It follows the patt
3838
```shell
3939
$ ember new super-rentals --lang en
4040
installing app
41-
Ember CLI v4.5.0
41+
Ember CLI v4.10.0
4242

4343
Creating a new Ember app in /home/runner/work/super-rentals-tutorial/super-rentals-tutorial/dist/code/super-rentals:
4444
create .editorconfig
@@ -75,7 +75,6 @@ Creating a new Ember app in /home/runner/work/super-rentals-tutorial/super-renta
7575
create tests/integration/.gitkeep
7676
create tests/test-helper.js
7777
create tests/unit/.gitkeep
78-
create vendor/.gitkeep
7978

8079
Installing packages... This might take a couple of minutes.
8180
npm: Installing dependencies ...
@@ -140,8 +139,6 @@ super-rentals
140139
│ │ └── .gitkeep
141140
│ ├── index.html
142141
│ └── test-helper.js
143-
├── vendor
144-
│ └── .gitkeep
145142
├── .editorconfig
146143
├── .ember-cli
147144
├── .eslintcache
@@ -158,25 +155,25 @@ super-rentals
158155
├── package-lock.json
159156
└── testem.js
160157
161-
17 directories, 36 files
158+
16 directories, 35 files
162159
```
163160

164161
We'll learn about the purposes of these files and folders as we go. For now, just know that we'll spend most of our time working within the `app` folder.
165162

166163
## Starting and Stopping the Development Server
167164

168-
Ember CLI comes with a lot of different commands for a variety of development tasks, such as the `ember new` command that we saw earlier. It also comes with a _development server_, which we can launch with the `ember server` command:
165+
Ember CLI comes with a lot of different commands for a variety of development tasks, such as the `ember new` command that we saw earlier. It also comes with a _development server_, which we can launch with the `ember serve` command:
169166

170167
```shell
171-
$ ember server
168+
$ ember serve
172169
building...
173170

174171
Build successful (9761ms) – Serving on http://localhost:4200/
175172
```
176173

177174
The development server is responsible for compiling our app and serving it to the browsers. It may take a while to boot up. Once it's up and running, open your favorite browser and head to <http://localhost:4200>. You should see the following welcome page:
178175

179-
<img src="/images/tutorial/part-1/orientation/[email protected]" alt="Welcome to Ember!" width="1024" height="906">
176+
<img src="/images/tutorial/part-1/orientation/[email protected]" alt="Welcome to Ember!" width="1024" height="919">
180177

181178
<div class="cta">
182179
<div class="cta-note">
@@ -190,7 +187,7 @@ The development server is responsible for compiling our app and serving it to th
190187
</div>
191188
</div>
192189

193-
You can exit out of the development server at any time by typing `Ctrl + C` into the terminal window where `ember server` is running. That is, typing the "C" key on your keyboard _while_ holding down the "Ctrl" key at the same time. Once it has stopped, you can start it back up again with the same `ember server` command. We recommend having two terminal windows open: one to run the server in background, another to type other Ember CLI commands.
190+
You can exit out of the development server at any time by typing `Ctrl + C` into the terminal window where `ember serve` is running. That is, typing the "C" key on your keyboard _while_ holding down the "Ctrl" key at the same time. Once it has stopped, you can start it back up again with the same `ember server` command. We recommend having two terminal windows open: one to run the server in background, another to type other Ember CLI commands.
194191

195192
## Editing Files and Live Reload
196193

guides/v4.10.0/tutorial/part-1/reusable-components.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The last missing feature for the `<Rental>` component is a map to show the location of the rental, which is what we're going to work on next:
44

5-
<img src="/images/tutorial/part-1/reusable-components/[email protected]" alt="The Super Rentals app by the end of the chapter" width="1024" height="1129">
5+
<img src="/images/tutorial/part-1/reusable-components/[email protected]" alt="The Super Rentals app by the end of the chapter" width="1024" height="1130">
66

77
While adding the map, you will learn about:
88

@@ -24,17 +24,18 @@ If you're curious, you can explore the options available on Mapbox by using the
2424

2525
Once you have signed up for the service, grab your _[default public token](https://account.mapbox.com/access-tokens/)_ and paste it into `config/environment.js`:
2626

27-
```js { data-filename="config/environment.js" data-diff="+47,+48" }
27+
```js { data-filename="config/environment.js" data-diff="+48,+49" }
2828
'use strict';
2929

3030
module.exports = function (environment) {
31-
let ENV = {
31+
const ENV = {
3232
modulePrefix: 'super-rentals',
3333
environment,
3434
rootURL: '/',
3535
locationType: 'history',
3636
EmberENV: {
3737
RAISE_ON_DEPRECATION: true,
38+
EXTEND_PROTOTYPES: false,
3839
FEATURES: {
3940
// Here you can enable experimental features on an ember canary build
4041
// e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
@@ -95,10 +96,10 @@ After saving the changes to our configuration file, we will need to restart our
9596

9697
<!-- TODO: https://github.com/ember-cli/ember-cli/issues/8782 -->
9798

98-
You can stop the server by finding the terminal window where `ember server` is running, then type `Ctrl + C`. That is, typing the "C" key on your keyboard _while_ holding down the "Ctrl" key at the same time. Once it has stopped, you can start it back up again with the same `ember server` command.
99+
You can stop the server by finding the terminal window where `ember serve` is running, then type `Ctrl + C`. That is, typing the "C" key on your keyboard _while_ holding down the "Ctrl" key at the same time. Once it has stopped, you can start it back up again with the same `ember server` command.
99100

100101
```shell
101-
$ ember server
102+
$ ember serve
102103
building...
103104

104105
Build successful (13286ms) – Serving on http://localhost:4200/
@@ -115,6 +116,8 @@ installing component
115116
create app/components/map.hbs
116117
installing component-test
117118
create tests/integration/components/map-test.js
119+
120+
Running "lint:fix" script...
118121
```
119122

120123
Since not every component will necessarily have some defined behavior associated with it, the component generator does not generate a JavaScript file for us by default. As we saw earlier, we can always use the `component-class` generator to add a JavaScript file for a component later on.
@@ -331,7 +334,7 @@ Hey, all the tests passed! But does that mean it actually works in practice? Let
331334
332335
Hey! That's a map!
333336

334-
<img src="/images/tutorial/part-1/reusable-components/[email protected]" alt="Three Grand Old Mansions" width="1024" height="1129">
337+
<img src="/images/tutorial/part-1/reusable-components/[email protected]" alt="Three Grand Old Mansions" width="1024" height="1130">
335338

336339
<!-- TODO: https://github.com/ember-cli/ember-cli/issues/8782 -->
337340

0 commit comments

Comments
 (0)