本文地址:?[http://blog.csdn.net/sushengmiyan/article/details/38295575](http://blog.csdn.net/sushengmiyan/article/details/38295575)
本文作者:[sushengmiyan](http://blog.csdn.net/sushengmiyan)
-------------------------------------------------------------資源鏈接-----------------------------------------------------------------------
翻譯來源 ?Sencha Cmd官方網站: ? ?[http://www.sencha.com/products/extjs/up-and-running/cmd-introduction](http://www.sencha.com/products/extjs/up-and-running/cmd-introduction)
Java se 8 下載官方網址: ? ? ? ? ? ? ? ? ? ?[http://www.oracle.com/technetwork/java/javase/downloads/index.html?ssSourceSiteId=ocomen](http://www.oracle.com/technetwork/java/javase/downloads/index.html?ssSourceSiteId=ocomen)
Sencha Cmd 官網下載: ? ? ? ? ? ? ? ? ? ??[https://www.sencha.com/products/extjs/cmd-download/](https://www.sencha.com/products/extjs/cmd-download/)
Ruby的安裝包下載地址: ? ? ? ? ? ? ? ? ? ??[http://rubyinstaller.org/](http://rubyinstaller.org/)
------------------------------------------------------------------------------------------------------------------------------------------------
### **Sencha Cmd的簡介**
~~~~~~~~~~~~~~~~~~~~~~~
?Sencha cmd 是一個跨平臺的命令行工具,它從你應用程序的新創建到部署入產品中的整個生命周期都提供了許多自動化的執行任務。
### 初遇Sencha Cmd
~~~~~~~~~~~~~~~~~~~~~
Sencha Cmd 提供了一系列功能強大的節約時間的功能,結合Sencha Ext JS 和Sencha Touch框架協同工作。Sencha Cmd 提供了如下幾個能力:
1.代碼生成工具:代碼生成工具生成整個應用程序并且擴展生成mvc的組件框架,如,使用sencha generate app 命令,可以自動幫你生成一個完成的應用程序目錄框架。
2.JS編譯:框架意識,Javascript 編譯器了解Sencha的語義語法,并且從你源代碼構建的時候產生較少的足跡。編譯器通過Sencha框架減少加載應用程序的時間來優化高層次的語義。
3.網絡服務:提供了輕量級的網絡服務,如,使用sencha web start 可以啟動網絡服務。
4.本地包裝:以一流的移動應用程序訪問設備給移動應用程序并且可以方便的分布到移動商店。
5.包裝管理系統:方便集成的由管理系統(像Ext js 的主題)
6.構建腳本. 通過在應用程序中增加“before”和"after"給應用程序增加一些額外的設置點讓客戶可以定制適合自己需求的腳本。
7.轉換工具:強大的代碼選擇器轉換你項目中需要最終構建需要的代碼,決定頁面和局部共享代碼的高級別選擇集像你需要的那樣構造。
8.工作空間管理:過不同的應用程序共享框架工作,包河自定義的代碼透。
9.圖像提取:轉換CSS3的特性(比如邊界半徑和線性梯度)
10.靈活的配置系統: 在一臺機器上允許命令行操作程序或者在工作空間級別或者整個工作空間。
11.日記功能:強大的日志功能幫助你理解整個內部的命令行工作,排除故障。
12.三方控件: Sencha cmd 包含了Compass sass 和ant 。
13.代碼生成的鉤子:可以指定到一個頁面或者在工作控件分享所有頁面,例如檢查daunting的慣例或者產生新的模型。
### 兼容性
~~~~~~~~
Sencha Cmd 支持Sencha Ext JS 的4.1.1a以及以上版本還有Sencha Touch的2.1版本以及以上,許多的新功能需要在框架的支持下工作,都是可以使用的版本。
對舊版本來說,有些低級命令式可以使用的。
如果你在使用舊版本的Ext JS 你可以使用Sencha Cmd的build命令來構造你的JSB文件。換句話說,Sencha Cmd 可以將JSB文件生成壓縮的構造包來替換之前版本,這操作不會更新你的那些有之前SDK生成的JSB文件。
Sencha Touch2.0和Sencha Ext JS 4.0 需要SDK2.0版本的工具,在以后的版本中是不會被支持的哦。
### 系統的安裝
~~~~~~~~~~~~~
下載一下安裝包并安裝到你的電腦:
1.JRE ? ?Sencha Cmd 需要Java的運行環境,需要1.7或者以上的java環境支持,最低要求也是到java的1.6版本。下載地址見最上方
2.Sencha Cmd 下載地址見上方
3.Ruby ? ruby的不同操作系統需要不同的版本,根據不同的操作系統下載不同的版本,具體就不介紹了。支持的版本,最好是ruby的1.7 下載網址見上方
### 成功安裝確認
~~~~~~~~~~~~~~~~
為了確保安裝的Sencha是成功的,需要打開命令行 即CMD 切換到安裝目錄下,輸入 sencha命令,如果看到 Sencha Cmd v5.x.x字樣,說明安裝成功。

如果不出現以上信息,需要你檢查上述步驟有無錯誤。
### **更新你的Sencha Cmd?**
~~~~~~~~~~~~~~~~~~~~~~~~~~~
執行命令 sencha upgrade --check
如果不帶--check 那么如果不急沒有安裝最新的版本的時候,就好給你下載并安裝。
Beta版本的發布
如果想獲取Beta版本,你需要使用sencha upgrade -- check --beta
### **Sencha基本命令**
~~~~~~~~~~~~~~~~~~~~
使用help命令
sencha help
~~~
Sencha Cmd v5.0.n.n
...
Options
* --cwd, -cw - Sets the directory from which commands should execute
* --debug, -d - Sets log level to higher verbosity
* --info, -i - Sets log level to default
* --nologo, -n - Suppress the initial Sencha Cmd version display
* --plain, -pl - enables plain logging output (no highlighting)
* --quiet, -q - Sets log level to warnings and errors only
* --sdk-path, -s - The location of the SDK to use for non-app commands
* --time, -ti - Display the execution time after executing all commands
Categories
* app - Perform various application build processes
* compass - Wraps execution of compass for sass compilation
* compile - Compile sources to produce concatenated output and metadata
* cordova - Manage Cmd/Cordova integration
* fs - Utility commands to work with files
* generate - Generates models, controllers, etc. or an entire application
* manifest - Extract class metadata
* package - Manages local and remote packages
* phonegap - Manage Cmd/PhoneGap integration
* repository - Manage local repository and remote repository connections
* theme - Commands for low-level operations on themes
* web - Manages a simple HTTP file server
Commands
* ant - Invoke Ant with helpful properties back to Sencha Cmd
* build - Builds a project from a legacy JSB3 file.
* config - Load a properties file or sets a configuration property
* help - Displays help for commands
* js - Executes arbitrary JavaScript file(s)
* upgrade - Upgrades Sencha Cmd
* which - Displays the path to the current version of Sencha Cmd
~~~
### **當前路徑**
~~~~~~~~~~
大多數情況下,sencha cmd 需要你設定一個特殊路徑,或者僅僅需要知道有關Sencha sdk的相關信息,SDK可以被自動檢測到當從文件夾建立應用程序的時候,有些命令可以從SDK文件夾抽取。
重要:在下面的命令中,Sencha cmd 需要從跟文件夾運行并產生一個應用程序。
Sencha generate...(可以有 app、package、workspace)
sencha app...
這個對包來說,也是成立的。當你運行如sencha package build 時當前路徑必須是包文件夾。
### **Sencha cmd 文檔**
~~~~~~~~~~~~~~~~~~~~~
許多sencma cmd的知道都是通過幫助組織建立你的認知的,它需要你遵循這些要求,如果跳躍的話,可能會得到一些令人疑惑的結果。
在每個指導的開始都是一些前期需要掌握的知識,更近一步,許多指導都以很多進一步的閱讀來結束。
### 基本知識以外
~~~~~~~~~~~~~~~
還有很多其他關于使用sencha cmd的命令的使用幫助細節,這些可以通過help命令來獲取更多幫助,但是如果你需要更高級的,那么需要下載advanced sencha cmd?
### **故障排除**
~~~~~~~~~~
如果在使用的時候在osx/linux操作系統出現了 sencha : command not found 的時候,或者在widows下出現了出現了 sencha is not recognized as an internal or external command ,operable program or bach file 你可以嘗試如下方法:
1.關閉所有命令行重新打開
2.確保sencha cmd是正確安裝的
不能找到ruby:
如果你看到關于ruby的時候,你很可能是ruby安裝的錯誤,重新看關于安裝ruby的問題。
不在當前目錄:
一個普遍的錯誤就是不在當前目錄運行,有時候需要制定SDK路徑但是你沒有制定的時候就會爆出這錯誤。
注意:一個有效的合法的路徑是你通過sencha cmd生成的。
當你解決依賴的時候出現的錯誤:
sencha app build命令通過讀取你的index.html來工作,掃描你的需要的類信息。如果你的應用程序沒有生命需要的類信息構造會完成但是不會包含所有的你應用程序需要類。
為了保證你把所有的需要的類加載進來,你可以使用調試命令行的方式來使用,比如使用ie的開發人員選項或者fiefox的fiebug功能,解決掉所有出現的警告燈問題。
當你看到如下警告的時候:
~~~
[Ext.Loader] Synchronously loading 'Ext.foo.Bar'; consider adding 'Ext.foo.Bar'
explicitly as a require of the corresponding class
~~~
立即將ext.foo.bar從requies數組中增加進去,如果需要的依賴比較多,那么就在requies的屬性數組中加入,實在Ext.application(...)語句中的。
- 前言
- [EXtJS5學習筆記]第一節 Sencha Cmd 學習筆記 簡介 Sencha Cmd是什么
- [ExtJS5學習筆記]第二節 Sencha Cmd 學習筆記 使你的sencha cmd跑起來
- [ExtJS5學習筆記]第三節 sencha cmd學習筆記 生成應用程序構建的內部細節
- [ExtJS5學習筆記]第四節 歡迎來到extjs5-手把手教你實現你的第一個應用
- [ExtJS5學習筆記]第五節 使用fontawesome給你的extjs5應用增加字體圖標
- [ExtJS5學習筆記]第六節 Extjs的類系統Class System命名規則及定義和調試
- [ExtJS5學習筆記]第七節 Extjs5的組件components及其模板事件方法學習
- [ExtJS5學習筆記]第八節 Extjs5的Ext.toolbar.Toolbar工具條組件及其應用
- [ExtJS5學習筆記]第九節 Extjs5的mvc與mvvm框架結構簡介
- [ExtJS5學習筆記]第十節 Extjs5新增特性之ViewModel和DataBinding
- [ExtJS5學習筆記]第十一節 Extjs5MVVM模式下系統登錄實例
- [ExtJS5學習筆記]第十二節 Extjs5開發遇到的問題列表記錄
- [ExtJS5學習筆記]第十三節 Extjs5的Ext.each方法學習
- [ExtJS5學習筆記]第十四節 Extjs5中data數據源store和datapanel學習
- [ExtJS5學習筆記]第十五節 Extjs5表格顯示不友好?panel的frame屬性在作怪
- [ExtJS5學習筆記]第十六節 Extjs5使用panel新增的ViewModel屬性綁定數據
- [ExtJS5學習筆記]第十七節 Extjs5的panel組件增加accodion成為折疊導航欄
- [ExtJS5學習筆記]第十八節 Extjs5的panel的dockeditems屬性配置toolbar
- [ExtJS5學習筆記]第十九節 Extjs5中通過設置form.Panel的FieldSet集合屬性控制多個field集合
- [ExtJS5學習筆記]第二十節 Extjs5配合數組的push方法,動態創建并加載組件
- [ExtJS5學習筆記]第二十一節 Extjs5中使用config配置給ext.widget或者create方法傳遞參數
- [ExtJS5學習筆記]第二十二節 Extjs5中使用beforeLabelTpl配置給標簽增加必填選項星號標志
- [ExtJS5學習筆記]第二十三節 Extjs5中表格gridpanel的列格式設置
- [ExtJS5學習筆記]第二十四節 Extjs5中表格gridpanel或者表單數據后臺傳輸remoteFilter設置
- [ExtJS5學習筆記]第二十五節 利用window.open()函數實現ExtJS5的登陸頁面跳轉
- [EXTJS5學習筆記]第二十六節 在eclipse/myeclipse中使用sencha extjs的插件
- [ExtJS5學習筆記]第二十七節 CMD打包錯誤 Error C2009: YUI Parse Error (identifier is a reserved word => debugger;)
- [ExtJS5學習筆記]第二十八節 sencha ext js 5.1.0發布版本正式發布 extjs doc下載地址
- [ExtJS5學習筆記]第二十九節 sencha ext js 5.1.0中動態更換皮膚主題
- [ExtJS5學習筆記]第三十節 sencha extjs 5表格gridpanel分組匯總
- [ExtJS5學習筆記]第三十一節 sencha extjs 5使用cmd生成的工程部署到tomcat服務器
- [ExtJS5學習筆記]第三十二節 sencha extjs 5與struts2的ajax交互配置
- [ExtJS5學習筆記]第三十五節 sencha extjs 5 組件查詢方法總結