概要
利用パッケージをバージョンアップしたときの作業内容のメモです。
すこし手間取ったので備忘録も兼ねて投稿しました。
雛形作成
exampleテンプレートのtodosを利用してアプリケーションの雛形を作成します。
> meteor create --example todos rubytomato-todos
Created a new Meteor app in 'rubytomato-todos' (from 'todos' template).
To run your new app:
cd rubytomato-todos
meteor
If you are new to Meteor, try some of the learning resources here:
https://www.meteor.com/learn
作業内容
使用しているパッケージを確認したところ、iron:routerに新しいバージョンがあるという表記があったので更新してみます。
> meteor list
accounts-password 1.1.4 Password support for accounts
blaze-html-templates 1.0.1 Compile HTML templates into reactive UI with Meteor Blaze
check 1.1.0 Check whether a value matches a pattern
insecure 1.0.4 (For prototyping only) Allow all database writes from the client
iron:router 0.9.4* Routing specifically designed for Meteor
jquery 1.11.4 Manipulate the DOM using CSS selectors
less 2.5.1 Leaner CSS language
meteor-base 1.0.1 Packages that every Meteor app needs
mobile-experience 1.0.1 Packages for a great mobile user experience
mongo 1.1.3 Adaptor for using MongoDB and Minimongo over DDP
session 1.1.1 Session variable
standard-minifiers 1.0.2 Standard minifiers used with Meteor apps by default.
tracker 1.0.9 Dependency tracker to allow reactive callbacks
* New versions of these packages are available! Run 'meteor update' to try to update those packages to their latest versions. If your packages cannot be updated further, try typing
`meteor add <package>@<newVersion>` to see more information.
メッセージに記載されている方法でアップデートしようとしたところ、新旧のバージョンに互換性がないということでエラーになりました。
しかし、メッセージには--allow-incompatible-update
を付ければアップデートできるということが書かれているので試してみます。
> meteor add iron:router@1.0.12
=> Errors while adding packages:
While selecting package versions:
error: Potentially incompatible change required to top-level dependency: iron:router 1.0.12, was 0.9.4.
Constraints on package "iron:router":
* iron:router@1.0.12 <- top level
To allow potentially incompatible changes to top-level dependencies, you must pass --allow-incompatible-update on the command line.
--allow-incompatible-update
を付けて更新したところ、下記のとおりiron:routerのアップデートが出来ました。
> meteor add iron:router@1.0.12 --allow-incompatible-update
Currently using iron:router with version constraint 0.9.4.
The version constraint will be changed to 1.0.12.
Changes to your project's package version selections:
iron:controller added, version 1.0.12
iron:core* upgraded from 0.3.4 to 1.0.11
iron:dynamic-template* upgraded from 0.4.1 to 1.0.12
iron:layout* upgraded from 0.4.1 to 1.0.12
iron:location added, version 1.0.11
iron:middleware-stack added, version 1.0.11
iron:router* upgraded from 0.9.4 to 1.0.12
iron:url added, version 1.0.11
* These packages have been updated to new versions that are not backwards
compatible.
iron:router: Routing specifically designed for Meteor
アプリケーションの動作に問題がないか確認してみます。
> meteor run
[[[[[ ~\D\dev\meteor_workspace\rubytomato-todos ]]]]]
=> Started proxy.
=> Started MongoDB.
=> Started your app.
=> App running at: http://localhost:3000/
Type Control-C twice to stop.
動作確認したところtodoデータの表示が出来なかったので、chromeのコンソールを見ると
Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?
というワーニングメッセージが表示されていました。
このメッセージの内容で検索したところ、[Meteor v 1.0 and Iron:Router] (http://stackoverflow.com/questions/26629835/meteor-v-1-0-and-ironrouter)というページがあったので、この内容を参考に下記のようにソースコードを修正しました。
Router.route('listsShow', {
path: '/lists/:_id',
// subscribe to todos before the page is rendered but don't wait on the
// subscription, we'll just render the items as they arrive
onBeforeAction: function () {
this.todosHandle = Meteor.subscribe('todos', this.params._id);
if (this.ready()) {
// Handle for launch screen defined in app-body.js
dataReadyHold.release();
}
+ this.next();
},
data: function () {
return Lists.findOne(this.params._id);
},
action: function () {
this.render();
}
});