SlideShare a Scribd company logo
1 of 14
Download to read offline
Plugmancode reading
Plugman = version": "0.21.1-dev"
plugman
• Plugman is ..
• A command line tool to install and
uninstall plugins for use with Apache
Cordova projects.
• https://github.com/apache/cordova-
plugman
plugman install
plugman install
--plugins_dir plugins
--plugin com.phonegap.plugins.barcodescanner
--platform android
--project android/native
--www android/js
pluginが保管されている場所
pluginの名前
対象プラットフォーム
android用のプラグインファイル

(java, libs )を配置する対象ディレクトリ
plugins/*.js
cordova_plugins.js
が配置される
ex) platform android
files
• このあたりを見る
• main.js
• plugman.js
• install.js
• prepare.js
main.js
• 一番始めに呼ばれる
• cli のオプションの検証
• plugman のconsole eventの設定
• オプションに基づいた plugman の関数の実行
!
• commands は plugman.js 内で定義される
• ここでいう [cmd] は config, install などのコマンドのこと
L81. var result = plugman.commands[cmd](cli_opts);
plugman.js
• plugman のメイン部分
• plugman.commands の中に実行可能なコマンド列が並ぶ
• 実行される中身は、addPropertyで対応するモジュールをsrcからrequire
!
• 読み込んだ function を plugman objectのプロパティとして登録
L62. addProperty(plugman, 'install', './src/install', true);
install.js
src/install.js
• install command の中身
• Install flow
• installPlugin -> possiblyFetch -> runInstall -> handleInstall
• installPlugin(platform, project_dir, id, plugins_dir, options)
• platformのチェック
• possiblyFetch(actions, platform, project_dir, id,
plugins_dir, options)
• plugin の fetch を行い runInstall に進む
install.js / runInstall
• Plugin内にあるplugin.xml をパース、plugin名, IDを取得
• pluginがインストールされているかを確認
• 確認対象のファイルは platform 毎に違うので、platforms/*.js を参照する
• plugin がインストールされていなければ続く
• getEngines でplugin.xml に記載されている処理エンジンを取得(記載無しの
場合は default-engineを利用)
• util/default-engines.js に記述のあるengine であれば、scriptSrcのパスが
セットされる。存在しない場合は以下のルールで追加される。
<engines>	
    <engine name="cordova" version="1.8.1" />	
    <engine name="worklight" version="1.0.0" />	
</engines>
util/default-engines.js
[存在する場合]
L6. { 'platform':'*', 'scriptSrc': path.join(project_dir,'cordova','version') },
[存在しない場合]
{ 'name': theName, 'platform': engine.attrib["platform"], 'scriptSrc':path.resolve(plugin_dir,
engine.attrib["scriptSrc"]), 'minVersion' : engine.attrib["version"]}
install.js / runInstall
• 取得した engine のscriptSrcをchild_processで起動 :
callEngineScripts
• scriptSrcの中身は version を出力するシェル
• platforms/ios/cordova/version
• 実行可能なversionという名前のシェルがあるをチェックし
ている
• 取得したバージョンと plugin.xml に書いてあるバージョンを比
較して、サポートバージョンかどうかを確認 : checkEngines
install.js / runInstall
L223 - L333
• plugin.xml 内の preference があれば、コマンド引数
(options)に存在するかを確認。なければそこでコマンド
終了
• plugin.xml 内の dependency があれば、install済み
pluginを確認。無ければ、local, git からpluginを取得し
てくる (fetch.js)
• 準備完了。handleInstallを呼ぶ
handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir,
install_plugin_dir, filtered_variables, options.www_dir, options.is_top_level);
install.js / handleInstall
• plugin.xml の platform タグ内を対象に実際に
ファイルなどを移動させる
!
!
• platforms/*.js から対応するプラットフォーム
のコマンドを実行準備
var sourceFiles = platformTag.findall('./source-file'),
headerFiles = platformTag.findall('./header-file'),
resourceFiles = platformTag.findall('./resource-file'),
frameworkFiles = platformTag.findall('./framework[@custom="true"]'),
libFiles = platformTag.findall('./lib-file'),
assets = assets.concat(platformTag.findall('./asset'));
L516. actions.push(actions.createAction(handler[ source-file"].install,
install.js / handleInstall
• コピー先を決定してファイルを移動させる
!
!
• actions.process(platform, project_dir)
• 失敗したら uninstall が呼ばれる
• 成功すれば install 処理完了
[platforms/android.js]
install:function(source_el, plugin_dir, project_dir, plugin_id) {
var dest = path.join(source_el.attrib['target-dir'], path.basename(source_el.attrib['src']));
!
common.copyNewFile(plugin_dir, source_el.attrib['src'], project_dir, dest);
},
prepare.js
• plugin ファイルへの cordova.defineの追加
!
• cordova_plugins.js ファイルの作成
pluginファイルに自動挿入される
cordova.define( com.phonegap.plugins.
L182. scriptContent = 'cordova.define("' + moduleName + '",
function(require, exports, module) { ' + scriptContent + 'n});n';
L217: var final_contents = "cordova.define('cordova/plugin_list', function(require, exports, module) {n";
L218: final_contents += 'module.exports = ' + JSON.stringify(moduleObjects,null,' ') + ;n';
…
L226: fs.writeFileSync(path.join(wwwDir, 'cordova_plugins.js'), final_contents, 'utf-8');
End of Slides

More Related Content

What's hot

phpspecで始めるBDD
phpspecで始めるBDDphpspecで始めるBDD
phpspecで始めるBDDYuuki Takezawa
 
JavaScriptでWebDriverのテストコードを書きましょ
JavaScriptでWebDriverのテストコードを書きましょJavaScriptでWebDriverのテストコードを書きましょ
JavaScriptでWebDriverのテストコードを書きましょKohki Nakashima
 
Appsody でnodejsのアプリを立ち上げよう!
Appsody でnodejsのアプリを立ち上げよう!Appsody でnodejsのアプリを立ち上げよう!
Appsody でnodejsのアプリを立ち上げよう!Daisuke Hiraoka
 
nGrinder3 : だれもが簡単にできる性能テスト
nGrinder3 : だれもが簡単にできる性能テストnGrinder3 : だれもが簡単にできる性能テスト
nGrinder3 : だれもが簡単にできる性能テストJunHo Yoon
 
Klocwork 2018.0 アップデート
Klocwork 2018.0 アップデートKlocwork 2018.0 アップデート
Klocwork 2018.0 アップデートMasaru Horioka
 
OpenShift from Easy way to Hard ? Way
OpenShift from Easy way to Hard ? WayOpenShift from Easy way to Hard ? Way
OpenShift from Easy way to Hard ? Wayロフト くん
 
脆弱性もバグ、だからテストしよう PHPカンファンレス2015
脆弱性もバグ、だからテストしよう PHPカンファンレス2015脆弱性もバグ、だからテストしよう PHPカンファンレス2015
脆弱性もバグ、だからテストしよう PHPカンファンレス2015ichikaway
 
Alfresco勉強会#30 alfrescoとshareのJavaScriptをデバッグしよう
Alfresco勉強会#30 alfrescoとshareのJavaScriptをデバッグしようAlfresco勉強会#30 alfrescoとshareのJavaScriptをデバッグしよう
Alfresco勉強会#30 alfrescoとshareのJavaScriptをデバッグしようTomomi Kawabe
 
バージョン管理#01 -Subversion編-
バージョン管理#01 -Subversion編-バージョン管理#01 -Subversion編-
バージョン管理#01 -Subversion編-hakoika-itwg
 
Ansibleで始めるinfraTDD(初級編)
Ansibleで始めるinfraTDD(初級編)Ansibleで始めるinfraTDD(初級編)
Ansibleで始めるinfraTDD(初級編)佐久本正太
 
Alfresco勉強会#33 alfresco 5.1でコンテンツ自動削除を実装してみた
Alfresco勉強会#33 alfresco 5.1でコンテンツ自動削除を実装してみたAlfresco勉強会#33 alfresco 5.1でコンテンツ自動削除を実装してみた
Alfresco勉強会#33 alfresco 5.1でコンテンツ自動削除を実装してみたTasuku Otani
 
CakePHP 1 to 2 Migration tips 100
CakePHP 1 to 2 Migration tips 100CakePHP 1 to 2 Migration tips 100
CakePHP 1 to 2 Migration tips 100ichikaway
 
Klocwork C/C++解析チューニング 概要
Klocwork C/C++解析チューニング 概要Klocwork C/C++解析チューニング 概要
Klocwork C/C++解析チューニング 概要Masaru Horioka
 
継続的インテグレーション3分クッキング
継続的インテグレーション3分クッキング継続的インテグレーション3分クッキング
継続的インテグレーション3分クッキングTakayuki Kondou
 
認証機能で学ぶ Laravel 5 アプリケーション
認証機能で学ぶ Laravel 5 アプリケーション認証機能で学ぶ Laravel 5 アプリケーション
認証機能で学ぶ Laravel 5 アプリケーションMasashi Shinbara
 
Taming robotframework
Taming robotframeworkTaming robotframework
Taming robotframework泰 増田
 

What's hot (20)

phpspecで始めるBDD
phpspecで始めるBDDphpspecで始めるBDD
phpspecで始めるBDD
 
JavaScriptでWebDriverのテストコードを書きましょ
JavaScriptでWebDriverのテストコードを書きましょJavaScriptでWebDriverのテストコードを書きましょ
JavaScriptでWebDriverのテストコードを書きましょ
 
Appsody でnodejsのアプリを立ち上げよう!
Appsody でnodejsのアプリを立ち上げよう!Appsody でnodejsのアプリを立ち上げよう!
Appsody でnodejsのアプリを立ち上げよう!
 
nGrinder3 : だれもが簡単にできる性能テスト
nGrinder3 : だれもが簡単にできる性能テストnGrinder3 : だれもが簡単にできる性能テスト
nGrinder3 : だれもが簡単にできる性能テスト
 
cpanfile
cpanfilecpanfile
cpanfile
 
Klocwork 2018.0 アップデート
Klocwork 2018.0 アップデートKlocwork 2018.0 アップデート
Klocwork 2018.0 アップデート
 
MoteMote Compiler Plugin
MoteMote Compiler PluginMoteMote Compiler Plugin
MoteMote Compiler Plugin
 
OpenShift from Easy way to Hard ? Way
OpenShift from Easy way to Hard ? WayOpenShift from Easy way to Hard ? Way
OpenShift from Easy way to Hard ? Way
 
脆弱性もバグ、だからテストしよう PHPカンファンレス2015
脆弱性もバグ、だからテストしよう PHPカンファンレス2015脆弱性もバグ、だからテストしよう PHPカンファンレス2015
脆弱性もバグ、だからテストしよう PHPカンファンレス2015
 
Alfresco勉強会#30 alfrescoとshareのJavaScriptをデバッグしよう
Alfresco勉強会#30 alfrescoとshareのJavaScriptをデバッグしようAlfresco勉強会#30 alfrescoとshareのJavaScriptをデバッグしよう
Alfresco勉強会#30 alfrescoとshareのJavaScriptをデバッグしよう
 
Vagrant+Chef
Vagrant+ChefVagrant+Chef
Vagrant+Chef
 
バージョン管理#01 -Subversion編-
バージョン管理#01 -Subversion編-バージョン管理#01 -Subversion編-
バージョン管理#01 -Subversion編-
 
Niigata.pm #1
Niigata.pm #1Niigata.pm #1
Niigata.pm #1
 
Ansibleで始めるinfraTDD(初級編)
Ansibleで始めるinfraTDD(初級編)Ansibleで始めるinfraTDD(初級編)
Ansibleで始めるinfraTDD(初級編)
 
Alfresco勉強会#33 alfresco 5.1でコンテンツ自動削除を実装してみた
Alfresco勉強会#33 alfresco 5.1でコンテンツ自動削除を実装してみたAlfresco勉強会#33 alfresco 5.1でコンテンツ自動削除を実装してみた
Alfresco勉強会#33 alfresco 5.1でコンテンツ自動削除を実装してみた
 
CakePHP 1 to 2 Migration tips 100
CakePHP 1 to 2 Migration tips 100CakePHP 1 to 2 Migration tips 100
CakePHP 1 to 2 Migration tips 100
 
Klocwork C/C++解析チューニング 概要
Klocwork C/C++解析チューニング 概要Klocwork C/C++解析チューニング 概要
Klocwork C/C++解析チューニング 概要
 
継続的インテグレーション3分クッキング
継続的インテグレーション3分クッキング継続的インテグレーション3分クッキング
継続的インテグレーション3分クッキング
 
認証機能で学ぶ Laravel 5 アプリケーション
認証機能で学ぶ Laravel 5 アプリケーション認証機能で学ぶ Laravel 5 アプリケーション
認証機能で学ぶ Laravel 5 アプリケーション
 
Taming robotframework
Taming robotframeworkTaming robotframework
Taming robotframework
 

Viewers also liked

Private lens @ yahoo open hack day 2014
Private lens @ yahoo open hack day 2014Private lens @ yahoo open hack day 2014
Private lens @ yahoo open hack day 2014Motokazu Nishimura
 
Suika warenja - スイカ割れんじゃー -
Suika warenja - スイカ割れんじゃー -Suika warenja - スイカ割れんじゃー -
Suika warenja - スイカ割れんじゃー -Motokazu Nishimura
 
UXのための心理学(仮)
UXのための心理学(仮)UXのための心理学(仮)
UXのための心理学(仮)Naruhito Kubota
 
ユーザーエクスペリエンスとユーザー心理(仮)
ユーザーエクスペリエンスとユーザー心理(仮)ユーザーエクスペリエンスとユーザー心理(仮)
ユーザーエクスペリエンスとユーザー心理(仮)Naruhito Kubota
 
デザインの価値のお話
デザインの価値のお話デザインの価値のお話
デザインの価値のお話Naruhito Kubota
 
Freer Monads, More Extensible Effects
Freer Monads, More Extensible EffectsFreer Monads, More Extensible Effects
Freer Monads, More Extensible EffectsHiromi Ishii
 

Viewers also liked (8)

Sensmon couchdb
Sensmon couchdbSensmon couchdb
Sensmon couchdb
 
Private lens @ yahoo open hack day 2014
Private lens @ yahoo open hack day 2014Private lens @ yahoo open hack day 2014
Private lens @ yahoo open hack day 2014
 
Suika warenja - スイカ割れんじゃー -
Suika warenja - スイカ割れんじゃー -Suika warenja - スイカ割れんじゃー -
Suika warenja - スイカ割れんじゃー -
 
Lean geo-location-data-format
Lean geo-location-data-formatLean geo-location-data-format
Lean geo-location-data-format
 
UXのための心理学(仮)
UXのための心理学(仮)UXのための心理学(仮)
UXのための心理学(仮)
 
ユーザーエクスペリエンスとユーザー心理(仮)
ユーザーエクスペリエンスとユーザー心理(仮)ユーザーエクスペリエンスとユーザー心理(仮)
ユーザーエクスペリエンスとユーザー心理(仮)
 
デザインの価値のお話
デザインの価値のお話デザインの価値のお話
デザインの価値のお話
 
Freer Monads, More Extensible Effects
Freer Monads, More Extensible EffectsFreer Monads, More Extensible Effects
Freer Monads, More Extensible Effects
 

Similar to Plugman code-reading

Capistranoで自動デプロイ
Capistranoで自動デプロイCapistranoで自動デプロイ
Capistranoで自動デプロイtoyoshi
 
環境構築自動化ツールのご紹介
環境構築自動化ツールのご紹介環境構築自動化ツールのご紹介
環境構築自動化ツールのご紹介Etsuji Nakai
 
10分で作る Node.js Auto Scale 環境 with CloudFormation
10分で作る Node.js Auto Scale 環境 with CloudFormation10分で作る Node.js Auto Scale 環境 with CloudFormation
10分で作る Node.js Auto Scale 環境 with CloudFormationKazuyuki Honda
 
試して学べるクラウド技術! OpenShift
試して学べるクラウド技術! OpenShift試して学べるクラウド技術! OpenShift
試して学べるクラウド技術! OpenShiftEtsuji Nakai
 
Gws 20130315 gradle_handson
Gws 20130315 gradle_handsonGws 20130315 gradle_handson
Gws 20130315 gradle_handsonNobuhiro Sue
 
Klocwork カスタムチェッカー紹介
Klocwork カスタムチェッカー紹介Klocwork カスタムチェッカー紹介
Klocwork カスタムチェッカー紹介Masaru Horioka
 
はてなにおける継続的デプロイメントの現状と Docker の導入
はてなにおける継続的デプロイメントの現状と Docker の導入はてなにおける継続的デプロイメントの現状と Docker の導入
はてなにおける継続的デプロイメントの現状と Docker の導入Yu Nobuoka
 
成長を加速する minne の技術基盤戦略
成長を加速する minne の技術基盤戦略成長を加速する minne の技術基盤戦略
成長を加速する minne の技術基盤戦略Hiroshi SHIBATA
 
Dockerでデプロイ
DockerでデプロイDockerでデプロイ
Dockerでデプロイoshiro_seiya
 
10分でわかるFuelPHP @ 2013/04 FuelPHP入門ハンズオン vol.1
 10分でわかるFuelPHP @ 2013/04 FuelPHP入門ハンズオン vol.1 10分でわかるFuelPHP @ 2013/04 FuelPHP入門ハンズオン vol.1
10分でわかるFuelPHP @ 2013/04 FuelPHP入門ハンズオン vol.1kenjis
 
NPAPIを使ったandroid標準ブラウザの拡張方法
NPAPIを使ったandroid標準ブラウザの拡張方法NPAPIを使ったandroid標準ブラウザの拡張方法
NPAPIを使ったandroid標準ブラウザの拡張方法Naruto TAKAHASHI
 
サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方
サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方
サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方Yuki Morishita
 
13016 n分で作るtype scriptでnodejs
13016 n分で作るtype scriptでnodejs13016 n分で作るtype scriptでnodejs
13016 n分で作るtype scriptでnodejsTakayoshi Tanaka
 
Isomorphic web development with scala and scala.js
Isomorphic web development  with scala and scala.jsIsomorphic web development  with scala and scala.js
Isomorphic web development with scala and scala.jsTanUkkii
 
Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識shigeya
 

Similar to Plugman code-reading (20)

Capistranoで自動デプロイ
Capistranoで自動デプロイCapistranoで自動デプロイ
Capistranoで自動デプロイ
 
環境構築自動化ツールのご紹介
環境構築自動化ツールのご紹介環境構築自動化ツールのご紹介
環境構築自動化ツールのご紹介
 
はじめての Elastic Beanstalk
はじめての Elastic Beanstalkはじめての Elastic Beanstalk
はじめての Elastic Beanstalk
 
10分で作る Node.js Auto Scale 環境 with CloudFormation
10分で作る Node.js Auto Scale 環境 with CloudFormation10分で作る Node.js Auto Scale 環境 with CloudFormation
10分で作る Node.js Auto Scale 環境 with CloudFormation
 
Capistrano
CapistranoCapistrano
Capistrano
 
試して学べるクラウド技術! OpenShift
試して学べるクラウド技術! OpenShift試して学べるクラウド技術! OpenShift
試して学べるクラウド技術! OpenShift
 
Scoop!
Scoop!Scoop!
Scoop!
 
Gws 20130315 gradle_handson
Gws 20130315 gradle_handsonGws 20130315 gradle_handson
Gws 20130315 gradle_handson
 
Grails 2.0.0.M1の話
Grails 2.0.0.M1の話 Grails 2.0.0.M1の話
Grails 2.0.0.M1の話
 
Klocwork カスタムチェッカー紹介
Klocwork カスタムチェッカー紹介Klocwork カスタムチェッカー紹介
Klocwork カスタムチェッカー紹介
 
はてなにおける継続的デプロイメントの現状と Docker の導入
はてなにおける継続的デプロイメントの現状と Docker の導入はてなにおける継続的デプロイメントの現状と Docker の導入
はてなにおける継続的デプロイメントの現状と Docker の導入
 
成長を加速する minne の技術基盤戦略
成長を加速する minne の技術基盤戦略成長を加速する minne の技術基盤戦略
成長を加速する minne の技術基盤戦略
 
Dockerでデプロイ
DockerでデプロイDockerでデプロイ
Dockerでデプロイ
 
10分でわかるFuelPHP @ 2013/04 FuelPHP入門ハンズオン vol.1
 10分でわかるFuelPHP @ 2013/04 FuelPHP入門ハンズオン vol.1 10分でわかるFuelPHP @ 2013/04 FuelPHP入門ハンズオン vol.1
10分でわかるFuelPHP @ 2013/04 FuelPHP入門ハンズオン vol.1
 
NPAPIを使ったandroid標準ブラウザの拡張方法
NPAPIを使ったandroid標準ブラウザの拡張方法NPAPIを使ったandroid標準ブラウザの拡張方法
NPAPIを使ったandroid標準ブラウザの拡張方法
 
Driverについて
DriverについてDriverについて
Driverについて
 
サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方
サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方
サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方
 
13016 n分で作るtype scriptでnodejs
13016 n分で作るtype scriptでnodejs13016 n分で作るtype scriptでnodejs
13016 n分で作るtype scriptでnodejs
 
Isomorphic web development with scala and scala.js
Isomorphic web development  with scala and scala.jsIsomorphic web development  with scala and scala.js
Isomorphic web development with scala and scala.js
 
Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識Windows PowerShell 2.0 の基礎知識
Windows PowerShell 2.0 の基礎知識
 

Plugman code-reading

  • 1. Plugmancode reading Plugman = version": "0.21.1-dev"
  • 2. plugman • Plugman is .. • A command line tool to install and uninstall plugins for use with Apache Cordova projects. • https://github.com/apache/cordova- plugman
  • 3. plugman install plugman install --plugins_dir plugins --plugin com.phonegap.plugins.barcodescanner --platform android --project android/native --www android/js pluginが保管されている場所 pluginの名前 対象プラットフォーム android用のプラグインファイル
 (java, libs )を配置する対象ディレクトリ plugins/*.js cordova_plugins.js が配置される ex) platform android
  • 4. files • このあたりを見る • main.js • plugman.js • install.js • prepare.js
  • 5. main.js • 一番始めに呼ばれる • cli のオプションの検証 • plugman のconsole eventの設定 • オプションに基づいた plugman の関数の実行 ! • commands は plugman.js 内で定義される • ここでいう [cmd] は config, install などのコマンドのこと L81. var result = plugman.commands[cmd](cli_opts);
  • 6. plugman.js • plugman のメイン部分 • plugman.commands の中に実行可能なコマンド列が並ぶ • 実行される中身は、addPropertyで対応するモジュールをsrcからrequire ! • 読み込んだ function を plugman objectのプロパティとして登録 L62. addProperty(plugman, 'install', './src/install', true);
  • 7. install.js src/install.js • install command の中身 • Install flow • installPlugin -> possiblyFetch -> runInstall -> handleInstall • installPlugin(platform, project_dir, id, plugins_dir, options) • platformのチェック • possiblyFetch(actions, platform, project_dir, id, plugins_dir, options) • plugin の fetch を行い runInstall に進む
  • 8. install.js / runInstall • Plugin内にあるplugin.xml をパース、plugin名, IDを取得 • pluginがインストールされているかを確認 • 確認対象のファイルは platform 毎に違うので、platforms/*.js を参照する • plugin がインストールされていなければ続く • getEngines でplugin.xml に記載されている処理エンジンを取得(記載無しの 場合は default-engineを利用) • util/default-engines.js に記述のあるengine であれば、scriptSrcのパスが セットされる。存在しない場合は以下のルールで追加される。 <engines>     <engine name="cordova" version="1.8.1" />     <engine name="worklight" version="1.0.0" /> </engines> util/default-engines.js [存在する場合] L6. { 'platform':'*', 'scriptSrc': path.join(project_dir,'cordova','version') }, [存在しない場合] { 'name': theName, 'platform': engine.attrib["platform"], 'scriptSrc':path.resolve(plugin_dir, engine.attrib["scriptSrc"]), 'minVersion' : engine.attrib["version"]}
  • 9. install.js / runInstall • 取得した engine のscriptSrcをchild_processで起動 : callEngineScripts • scriptSrcの中身は version を出力するシェル • platforms/ios/cordova/version • 実行可能なversionという名前のシェルがあるをチェックし ている • 取得したバージョンと plugin.xml に書いてあるバージョンを比 較して、サポートバージョンかどうかを確認 : checkEngines
  • 10. install.js / runInstall L223 - L333 • plugin.xml 内の preference があれば、コマンド引数 (options)に存在するかを確認。なければそこでコマンド 終了 • plugin.xml 内の dependency があれば、install済み pluginを確認。無ければ、local, git からpluginを取得し てくる (fetch.js) • 準備完了。handleInstallを呼ぶ handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir, install_plugin_dir, filtered_variables, options.www_dir, options.is_top_level);
  • 11. install.js / handleInstall • plugin.xml の platform タグ内を対象に実際に ファイルなどを移動させる ! ! • platforms/*.js から対応するプラットフォーム のコマンドを実行準備 var sourceFiles = platformTag.findall('./source-file'), headerFiles = platformTag.findall('./header-file'), resourceFiles = platformTag.findall('./resource-file'), frameworkFiles = platformTag.findall('./framework[@custom="true"]'), libFiles = platformTag.findall('./lib-file'), assets = assets.concat(platformTag.findall('./asset')); L516. actions.push(actions.createAction(handler[ source-file"].install,
  • 12. install.js / handleInstall • コピー先を決定してファイルを移動させる ! ! • actions.process(platform, project_dir) • 失敗したら uninstall が呼ばれる • 成功すれば install 処理完了 [platforms/android.js] install:function(source_el, plugin_dir, project_dir, plugin_id) { var dest = path.join(source_el.attrib['target-dir'], path.basename(source_el.attrib['src'])); ! common.copyNewFile(plugin_dir, source_el.attrib['src'], project_dir, dest); },
  • 13. prepare.js • plugin ファイルへの cordova.defineの追加 ! • cordova_plugins.js ファイルの作成 pluginファイルに自動挿入される cordova.define( com.phonegap.plugins. L182. scriptContent = 'cordova.define("' + moduleName + '", function(require, exports, module) { ' + scriptContent + 'n});n'; L217: var final_contents = "cordova.define('cordova/plugin_list', function(require, exports, module) {n"; L218: final_contents += 'module.exports = ' + JSON.stringify(moduleObjects,null,' ') + ;n'; … L226: fs.writeFileSync(path.join(wwwDir, 'cordova_plugins.js'), final_contents, 'utf-8');