|
1 | 1 | h2 do
|
2 |
| - span "If you haven't yet deployed to heroku, start at " |
3 |
| - a 'First-time setup', href: '#first-time' |
| 2 | + span "如果你從來沒有把程式 deploy 到 Heroku 過,請看" |
| 3 | + a '第一次 deploy 的方法', href: '#first-time' |
4 | 4 | span ". Otherwise, start at "
|
5 |
| - a 'Every time', href: '#every-time' |
| 5 | + a 'deploy 新版程式的方法', href: '#every-time' |
6 | 6 | span "."
|
7 | 7 | end
|
8 | 8 |
|
9 | 9 | a name: 'first-time'
|
10 |
| -situation "First-time setup" do |
11 |
| - step "Create a heroku application" do |
| 10 | +situation "第一次 deploy 的方法" do |
| 11 | + step "開新 Heroku 應用程式" do |
12 | 12 | console "heroku create"
|
13 |
| - message "`heroku create` registers a new application on heroku's system. You should see some output including your new app's URL." |
| 13 | + message "`heroku create` 會在 Heroku 的系統裡面註冊新的應用程式。跑完之後你應該會看到輸出裡面告訴你新的應用程式的 URL。" |
14 | 14 | end
|
15 | 15 |
|
16 |
| - step "Edit the Gemfile" do |
17 |
| - important "Each application has its own `Gemfile`. Be sure you're opening the one inside your app's folder." |
| 16 | + step "修改 Gemfile" do |
| 17 | + important "每個 Rails 程式都有他自己的 `Gemfile`。請確定你開的是你的 Rails 程式的 Gemfile。" |
18 | 18 |
|
19 |
| - message "Heroku will run our application slightly differently than our development computer does, which requires us to make a small change to our `Gemfile`." |
| 19 | + message "Heroku 執行我們程式的方法跟我們在本地開發環境執行的方法有點不同,所以我們要改一下 `Gemfile`。" |
20 | 20 |
|
21 |
| - message "Open the file called `Gemfile` in Sublime Text, or your preferred editor, and find the line containing:" |
| 21 | + message "在編輯器打開 `Gemfile`,找這一行:" |
22 | 22 |
|
23 | 23 | source_code :ruby, <<-RUBY
|
24 | 24 | gem 'sqlite3'
|
25 | 25 | RUBY
|
26 | 26 |
|
27 |
| - message "**Remove that line** and replace it with:" |
| 27 | + message "**刪除那一行**,改成這樣:" |
28 | 28 |
|
29 | 29 | source_code :ruby, <<-RUBY
|
30 | 30 | group :development, :test do
|
|
38 | 38 | RUBY
|
39 | 39 | end
|
40 | 40 |
|
41 |
| - step "Apply the Gemfile changes" do |
| 41 | + step "套用 Gemfile 的異動" do |
42 | 42 | console "bundle install --without production"
|
43 |
| - message "Every time the Gemfile changes, you need to run ``bundle install`` for the changes to be processed. The processed version of the changes is stored in another file called ``Gemfile.lock``." |
| 43 | + message "每當你改 Gemfile 的時候,你都要跑一次 ``bundle install``,這樣子異動才會被套用。套用之後的異動會被存在另一個檔案 ``Gemfile.lock``。" |
44 | 44 | end
|
45 | 45 |
|
46 |
| - step "Commit the Gemfile changes" do |
47 |
| - message "There are now changes to Gemfile and Gemfile.lock that need to be committed before we can push to heroku." |
| 46 | + step "把 Gemfile 的異動 commit 進 git" do |
| 47 | + message "現在 Gemfile 和 Gemfile.lock 修改過了,在上傳到 Heroku 之前,我們要把這些異動 commit 進 git。" |
48 | 48 | console <<-SHELL
|
49 | 49 | git add .
|
50 |
| -git commit -m "Changed Gemfile for heroku" |
| 50 | +git commit -m "改 Gemfile 來適應 heroku" |
51 | 51 | SHELL
|
52 |
| - tip "There is a period after the word add in the first line." |
| 52 | + tip "第一行指令的最後面有一個小數點符號。" |
53 | 53 | end
|
54 | 54 | end
|
55 | 55 |
|
56 | 56 | a name: 'every-time'
|
57 |
| -situation "Every time" do |
58 |
| - step "Commit any pending changes to git" do |
59 |
| - message "Heroku will only receive the files we've committed into our local git repository. So we need to make sure all changed files have been committed." |
| 57 | +situation "deploy 新版程式的方法" do |
| 58 | + step "把所有異動都 commit 進 git" do |
| 59 | + message "Heroku 只受理我們有 commit 進本地 git repo 的程式,所以要確定修改過的檔案都有 commit 進去了。" |
60 | 60 | console "git status"
|
61 |
| - message "`git status` shows you any pending changes you've created. If it has no output, you're already ready to deploy! Otherwise..." |
| 61 | + message "`git status` 顯示你還沒 commit 進 git 的異動。如果沒有輸出任何東西的話,那你可以 deploy 了!不然的話就要 commit 程式碼進去:" |
62 | 62 |
|
63 | 63 | console <<-SHELL
|
64 | 64 | git add .
|
65 | 65 | git commit -m "Some helpful message for your future self"
|
66 | 66 | SHELL
|
67 |
| - message "Your commit message should reference whatever your outstanding changes are: something like 'added votes to the topics index'." |
| 67 | + message "Commit message 應該要可以描述你這次修改了什麼東西,像是:「把投票數加到 topics 列表頁」" |
68 | 68 | end
|
69 | 69 |
|
70 |
| - step "Push changes to heroku" do |
| 70 | + step "把異動 push(上傳)到 Heroku" do |
71 | 71 | console "git push heroku master"
|
72 |
| - message "This takes all changes you've committed locally and pushes them to heroku." |
| 72 | + message "這樣子會把本地所有已經 commit 進去的異動都 push 到 Heroku。" |
73 | 73 | end
|
74 | 74 |
|
75 |
| - step "Run database migrations on Heroku" do |
| 75 | + step "在 Heroku 跑資料庫的 migration" do |
76 | 76 | console "heroku run rake db:migrate"
|
77 |
| - message "This tells Heroku to run your migrations on its database, like running rake db:migrate locally. Heroku's database is separate from the one on your computer, which means it needs to be updated every time you make changes to the structure of your database. It also means that you'll not see any of the data you entered into the sqlite3 database on your computer." |
| 77 | + message "這是叫 Heroku 在它的資料庫跑 migration,作用就像我們在本地跑 rake db:migrate。Heroku 的資料庫跟你電腦上的資料庫是分開的,也就是說每一次你更改了資料庫的結構,你都要在 Heroku 的資料庫更新一次。這也就是說在 Heroku 上面你不會看到你電腦上的 sqlite3 資料庫裡面的資料。" |
78 | 78 | end
|
79 | 79 |
|
80 |
| - step "Visit your application" do |
| 80 | + step "上網看你的程式" do |
81 | 81 | console "heroku open"
|
82 |
| - message "This opens the new application in your browser." |
| 82 | + message "會在瀏覽器打開你上傳到 Heroku 的程式。" |
83 | 83 | end
|
84 | 84 | end
|
85 | 85 |
|
86 | 86 | explanation do
|
87 | 87 | message <<-MARKDOWN
|
88 |
| - First, we had to do some work to make Heroku happy with our application. This required updating the Gemfile and bundling. |
89 |
| - |
90 |
| - * The Gemfile is a list of all the Ruby libraries your application needs. |
91 |
| - What we've declared here is that we want to use the `sqlite3` library |
92 |
| - while we're developing on our computer (the development group) but when |
93 |
| - deploying to heroku (the production group) we want to use the `pg` library, |
94 |
| - which is made for the type of database that heroku uses. |
95 |
| - |
96 |
| - * Bundler is how Ruby projects keep track of the gems that they use. We told |
97 |
| - bundler what we wanted to use in the `Gemfile`, now we need to make sure those |
98 |
| - gems are installed. Since we don't have the type of database heroku does, we |
99 |
| - skip the production gems. Don't worry though! Bundler still logs them so |
100 |
| - Heroku will install them when they get your code. |
| 88 | + 首先,我們要讓 Heroku 跟我們的程式可以整合。這需要修改 Gemfile 和重跑 bundler。 |
| 89 | + |
| 90 | + * Gemfile 這個檔案列出了所有你的 Rails 程式所需要的 Ruby 程式庫(Library),稱為**「gem」**。 |
| 91 | + 我們這裡宣告的是說,要在自己電腦的開發環境使用 `sqlite3` gem(寫在 development group 裡面), |
| 92 | + 但是在上傳到 Heroku(production group)的時候要使用 `pg` gem,這是專門設計給 Heroku 使用的資料庫。 |
| 93 | + |
| 94 | + * Bundler 是 Ruby 專案用來追蹤有使用哪些 gem 的工具。我們透過 `Gemfile` 跟 Bundler |
| 95 | + 說我們要什麼 gem,然後我們要確定這些 gem 都有安裝。因為我們目前電腦裡面沒有 Heroku 用的資料庫系統, |
| 96 | + 所以我們跳過不安裝 production 用的 gem。別擔心,Bundler 還是會幫我們記得,讓 Heroku 幫你安裝。 |
101 | 97 | MARKDOWN
|
102 | 98 |
|
103 |
| - message "You should be able to deploy your application any time it's in a good, working state. Your typical workflow will look like:" |
| 99 | + message "你可以在任何你的程式沒問題、會動的時候 deploy。標準流程長得像這樣:" |
104 | 100 | img src: "img/workflow.png", alt: "workflow", style: "border: none"
|
105 | 101 | ol do
|
106 |
| - li { message "Add or change some code" } |
107 |
| - li { message "Commit your changes (`git commit`)" } |
108 |
| - li { message "(repeat)" } |
| 102 | + li { message "改程式" } |
| 103 | + li { message "把異動 commit 進 git(`git commit`)" } |
| 104 | + li { message "(重複)" } |
109 | 105 | end
|
110 |
| - message "Any time your changes are committed, you should feel free to `git push heroku master` and boom! Your changes are live!" |
| 106 | + message "每當你把異動 commit 進 git 之後,你都可以執行 `git push heroku master`,然後新版本就上線了!" |
111 | 107 | end
|
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
0 commit comments