Meteor常用资源

Meteor常用命令

meteor help <command> 查看特定命令帮助
meteor create <project_name> 创建Meteor项目
meteor create --list 查看有哪些示例项目
meteor create --example <name>' 创建示例项目
meteor create --package <package_name> 创建本地Meteor包
meteor run <ios|android> 在iOS或Android模拟环境下运行
meteor add <package_name> 添加包
meteor remove <package_name> 删除包
meteor add-platform <ios|android> 添加iOS或Android运行环境

Meteor常用目录结构

  • Root-Level Folders - 基于Feature划分目录
  • Folders inside client/ and server/ - 基于client/server划分目录
  • Packages - 基于Package划分目录

推荐client/server方式

mkdir client server lib public client/js client/stylesheets client/templates lib/collections

Meteor文件加载顺序

  1. 首先加载HTML模版文件,后加载js等其他文件
  2. 在任何lib/文件夹下的文件将随后加载
  3. 同优先级目录由深到浅加载文件
  4. 在整个路径中文件以字母顺序加载
  5. 以main.开头的文件将最后加载

Meteor文件命名规范

lib/                      # common code like collections and utilities
lib/methods.js            # Meteor.methods definitions
lib/constants.js          # constants used in the rest of the code

client/compatibility      # legacy libraries that expect to be global
client/lib/               # code for the client to be loaded first
client/lib/helpers.js     # useful helpers for your client code
client/body.html          # content that goes in the <body> of your HTML
client/head.html          # content for <head> of your HTML: <meta> tags, etc
client/style.css          # some CSS code
client/<feature>.html     # HTML templates related to a certain feature
client/<feature>.js       # JavaScript code related to a certain feature

server/lib/permissions.js # sensitive permissions code used by your server
server/publications.js    # Meteor.publish definitions

public/favicon.ico        # app icon

settings.json             # configuration data to be passed to meteor --settings
mobile-config.js          # define icons and metadata for Android/iOS

Meteor扩展包

Package大体分为三种:

  1. 官方扩展包,如meteor-platform,insecure,autopublish,accounts-password等
  2. 社区贡献包,如iron:router,twbs:bootstrap等
  3. 本地包,由用户自己创建的包

扩展包查询:https://atmospherejs.com

常见包目录

  • 全局包目录位置: ~/.meteor/packages
  • 项目包依赖列表: /.meteor/packages
  • 本地包目录位置: /packages

创建本地包

meteor create --package <package_name>