Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B4C8B1815C for ; Wed, 27 May 2015 20:07:17 +0000 (UTC) Received: (qmail 7801 invoked by uid 500); 27 May 2015 20:06:55 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 7666 invoked by uid 500); 27 May 2015 20:06:55 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 7638 invoked by uid 99); 27 May 2015 20:06:55 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 May 2015 20:06:55 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 6A840AC073A for ; Wed, 27 May 2015 20:06:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1682113 [2/6] - in /cordova/site: public/ public/announcements/2015/05/ public/announcements/2015/05/26/ public/blog/ public/docs/de/edge/ public/docs/en/edge/ public/docs/zh/3.5.0/ public/docs/zh/edge/ public/docs/zh/edge/img/guide/platfo... Date: Wed, 27 May 2015 20:06:54 -0000 To: commits@cordova.apache.org From: steven@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150527200655.6A840AC073A@hades.apache.org> Added: cordova/site/public/docs/de/edge/cordova_storage_sqlresultset_sqlresultset.md.html URL: http://svn.apache.org/viewvc/cordova/site/public/docs/de/edge/cordova_storage_sqlresultset_sqlresultset.md.html?rev=1682113&view=auto ============================================================================== --- cordova/site/public/docs/de/edge/cordova_storage_sqlresultset_sqlresultset.md.html (added) +++ cordova/site/public/docs/de/edge/cordova_storage_sqlresultset_sqlresultset.md.html Wed May 27 20:06:53 2015 @@ -0,0 +1,297 @@ + + + + + + + + + + Apache Cordova API Documentation + + + + + + + +
+

SQLResultSet

+ +
+ + + +
+
+

SQLResultSet

+

Wenn eine SQLTransaction des Objekts executeSql -Methode wird aufgerufen, der angegebene Rückruf führt mit einem SQLResultSet Parameter.

+

Eigenschaften

+
    +
  • InsertId: die Zeilen-ID der Zeile, die die SQLResultSet des Objekts-SQL-Anweisung, die in die Datenbank eingefügt.

    +
  • +
  • RowsAffected: die Anzahl der Zeilen geändert werden, indem die SQL-Anweisung, die 0 (null), wenn die Anweisung keine Zeilen nicht ausgewirkt hat.

    +
  • +
  • Zeilen: eine SQLResultSetRowList , die die zurückgegebenen Zeilen darstellen, empty, wenn keine Zeilen zurückgegeben werden.

    +
  • +
+

Informationen

+

Wenn eine SQLTransaction des Objekts executeSql -Methode wird aufgerufen, der angegebene Rückruf führt mit einer SQLResultSet Parameter mit den drei Eigenschaften:

+
    +
  • Die insertId gibt die Zeilennummer einer successly SQL-Einfügung-Anweisung zurück. Wenn die SQL keine Zeilen einfügen wird die insertId nicht festgelegt.

    +
  • +
  • Die rowsAffected ist immer ` für ein SQLselectAnweisung. Fürinsertoderupdate` es die Anzahl der gibt Anweisungen geänderter Zeilen.

    +
  • +
  • Finale SQLResultSetList enthält die Daten aus einer SQL-select-Anweisung zurückgegeben.

    +
  • +
+

Unterstützte Plattformen

+
    +
  • Android
  • +
  • BlackBerry WebWorks (OS 6.0 und höher)
  • +
  • iOS
  • +
  • Tizen
  • +
+

Führen Sie SQL-schnelles-Beispiel

+
function queryDB(tx) {
+    tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
+}
+
+function querySuccess(tx, results) {
+    console.log("Returned rows = " + results.rows.length);
+    // this will be true since it was a select statement and so rowsAffected was 0
+    if (!results.rowsAffected) {
+        console.log('No rows affected!');
+        return false;
+    }
+    // for an insert statement, this property will return the ID of the last inserted row
+    console.log("Last inserted row ID = " + results.insertId);
+}
+
+function errorCB(err) {
+    alert("Error processing SQL: "+err.code);
+}
+
+var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
+db.transaction(queryDB, errorCB);
+

Vollständiges Beispiel

+
<!DOCTYPE html>
+<html>
+  <head>
+    <title>Storage Example</title>
+
+    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
+    <script type="text/javascript" charset="utf-8">
+
+    // Wait for device API libraries to load
+    //
+    document.addEventListener("deviceready", onDeviceReady, false);
+
+    // Populate the database
+    //
+    function populateDB(tx) {
+        tx.executeSql('DROP TABLE IF EXISTS DEMO');
+        tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
+        tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
+        tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
+    }
+
+    // Query the database
+    //
+    function queryDB(tx) {
+        tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
+    }
+
+    // Query the success callback
+    //
+    function querySuccess(tx, results) {
+        console.log("Returned rows = " + results.rows.length);
+        // this will be true since it was a select statement and so rowsAffected was 0
+        if (!results.rowsAffected) {
+            console.log('No rows affected!');
+            return false;
+        }
+        // for an insert statement, this property will return the ID of the last inserted row
+        console.log("Last inserted row ID = " + results.insertId);
+    }
+
+    // Transaction error callback
+    //
+    function errorCB(err) {
+        console.log("Error processing SQL: "+err.code);
+    }
+
+    // Transaction success callback
+    //
+    function successCB() {
+        var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
+        db.transaction(queryDB, errorCB);
+    }
+
+    // device APIs are available
+    //
+    function onDeviceReady() {
+        var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
+        db.transaction(populateDB, errorCB, successCB);
+    }
+
+    </script>
+  </head>
+  <body>
+    <h1>Example</h1>
+    <p>Database</p>
+  </body>
+</html>
+
+
+
+ + + + + + Added: cordova/site/public/docs/de/edge/cordova_storage_sqlresultsetrowlist_sqlresultsetrowlist.md.html URL: http://svn.apache.org/viewvc/cordova/site/public/docs/de/edge/cordova_storage_sqlresultsetrowlist_sqlresultsetrowlist.md.html?rev=1682113&view=auto ============================================================================== --- cordova/site/public/docs/de/edge/cordova_storage_sqlresultsetrowlist_sqlresultsetrowlist.md.html (added) +++ cordova/site/public/docs/de/edge/cordova_storage_sqlresultsetrowlist_sqlresultsetrowlist.md.html Wed May 27 20:06:53 2015 @@ -0,0 +1,282 @@ + + + + + + + + + + Apache Cordova API Documentation + + + + + + + +
+

SQLResultSetRowList

+ +
+ + + +
+
+

SQLResultSetRowList

+

Eine der Eigenschaften von den SQLResultSet mit den Zeilen aus einer SQL-Abfrage zurückgegeben.

+

Eigenschaften

+
    +
  • Länge: die Anzahl der Zeilen, die von der SQL-Abfrage zurückgegeben.
  • +
+

Methoden

+
    +
  • Element: liefert die Zeile am angegebenen Index durch ein JavaScript-Objekt dargestellt.
  • +
+

Informationen

+

Die SQLResultSetRowList enthält die Daten aus einer SQL zurückgegeben select Anweisung. Das Objekt enthält eine length Eigenschaft, die angibt, wie viele Zeilen der select Anweisung zurückgegeben. Um eine Zeile mit Daten abzurufen, rufen Sie die item -Methode, um einen Index angeben. Es gibt eine JavaScript Object deren Eigenschaften sind die Datenbankspalten der select Anweisung ausgeführt wurde.

+

Unterstützte Plattformen

+
    +
  • Android
  • +
  • BlackBerry WebWorks (OS 6.0 und höher)
  • +
  • iOS
  • +
  • Tizen
  • +
+

Führen Sie SQL-schnelles-Beispiel

+
function queryDB(tx) {
+    tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
+}
+
+function querySuccess(tx, results) {
+    var len = results.rows.length;
+        console.log("DEMO table: " + len + " rows found.");
+        for (var i=0; i<len; i++){
+            console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data =  " + results.rows.item(i).data);
+        }
+    }
+
+    function errorCB(err) {
+        alert("Error processing SQL: "+err.code);
+    }
+
+    var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
+    db.transaction(queryDB, errorCB);
+

Vollständiges Beispiel

+
<!DOCTYPE html>
+<html>
+  <head>
+    <title>Storage Example</title>
+
+    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
+    <script type="text/javascript" charset="utf-8">
+
+    // Wait for device API libraries to load
+    //
+    document.addEventListener("deviceready", onDeviceReady, false);
+
+    // Populate the database
+    //
+    function populateDB(tx) {
+        tx.executeSql('DROP TABLE IF EXISTS DEMO');
+        tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
+        tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
+        tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
+    }
+
+    // Query the database
+    //
+    function queryDB(tx) {
+        tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
+    }
+
+    // Query the success callback
+    //
+    function querySuccess(tx, results) {
+        var len = results.rows.length;
+        console.log("DEMO table: " + len + " rows found.");
+        for (var i=0; i<len; i++){
+            console.log("Row = " + i + " ID = " + results.rows.item(i).id + " Data =  " + results.rows.item(i).data);
+        }
+    }
+
+    // Transaction error callback
+    //
+    function errorCB(err) {
+        console.log("Error processing SQL: "+err.code);
+    }
+
+    // Transaction success callback
+    //
+    function successCB() {
+        var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
+        db.transaction(queryDB, errorCB);
+    }
+
+    // device APIs are available
+    //
+    function onDeviceReady() {
+        var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
+        db.transaction(populateDB, errorCB, successCB);
+    }
+
+    </script>
+  </head>
+  <body>
+    <h1>Example</h1>
+    <p>Database</p>
+  </body>
+</html>
+
+
+
+ + + + + + Added: cordova/site/public/docs/de/edge/cordova_storage_sqltransaction_sqltransaction.md.html URL: http://svn.apache.org/viewvc/cordova/site/public/docs/de/edge/cordova_storage_sqltransaction_sqltransaction.md.html?rev=1682113&view=auto ============================================================================== --- cordova/site/public/docs/de/edge/cordova_storage_sqltransaction_sqltransaction.md.html (added) +++ cordova/site/public/docs/de/edge/cordova_storage_sqltransaction_sqltransaction.md.html Wed May 27 20:06:53 2015 @@ -0,0 +1,260 @@ + + + + + + + + + + Apache Cordova API Documentation + + + + + + + +
+

SQLTransaction

+ +
+ + + +
+
+

SQLTransaction

+

Ermöglicht die Ausführung von SQL-Anweisungen für die Datenbank.

+

Methoden

+
    +
  • ExecuteSql: führt eine SQL­Anweisung.
  • +
+

Informationen

+

Aufrufen einer Database -Methode des Objekts Transaktion, Pässe ein SQLTransaction Objekt, das die angegebene Callback-Methode.

+

Unterstützte Plattformen

+
    +
  • Android
  • +
  • BlackBerry WebWorks (OS 6.0 und höher)
  • +
  • iOS
  • +
  • Tizen
  • +
+

Führen Sie SQL-schnelles-Beispiel

+
function populateDB(tx) {
+    tx.executeSql('DROP TABLE IF EXISTS DEMO');
+    tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
+    tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
+    tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
+}
+
+function errorCB(err) {
+    alert("Error processing SQL: "+err);
+}
+
+function successCB() {
+    alert("success!");
+}
+
+var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
+db.transaction(populateDB, errorCB, successCB);
+

Vollständiges Beispiel

+
<!DOCTYPE html>
+<html>
+  <head>
+    <title>Storage Example</title>
+
+    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
+    <script type="text/javascript" charset="utf-8">
+
+    // Wait for device API libraries to load
+    //
+    document.addEventListener("deviceready", onDeviceReady, false);
+
+    // device APIs are available
+    //
+    function onDeviceReady() {
+        var db = window.openDatabase("Database", "1.0", "Cordova Demo", 200000);
+        db.transaction(populateDB, errorCB, successCB);
+    }
+
+    // Populate the database
+    //
+    function populateDB(tx) {
+        tx.executeSql('DROP TABLE IF EXISTS DEMO');
+        tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
+        tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
+        tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
+    }
+
+    // Transaction error callback
+    //
+    function errorCB(err) {
+        alert("Error processing SQL: "+err);
+    }
+
+    // Transaction success callback
+    //
+    function successCB() {
+        alert("success!");
+    }
+
+    </script>
+  </head>
+  <body>
+    <h1>Example</h1>
+    <p>SQLTransaction</p>
+  </body>
+</html>
+
+
+
+ + + + + + Added: cordova/site/public/docs/de/edge/cordova_storage_storage.opendatabase.md.html URL: http://svn.apache.org/viewvc/cordova/site/public/docs/de/edge/cordova_storage_storage.opendatabase.md.html?rev=1682113&view=auto ============================================================================== --- cordova/site/public/docs/de/edge/cordova_storage_storage.opendatabase.md.html (added) +++ cordova/site/public/docs/de/edge/cordova_storage_storage.opendatabase.md.html Wed May 27 20:06:53 2015 @@ -0,0 +1,219 @@ + + + + + + + + + + Apache Cordova API Documentation + + + + + + + +
+

openDatabase

+ +
+ + + +
+
+

openDatabase

+

Gibt eine neue Database Objekt.

+
var dbShell = window.openDatabase(database_name, database_version, database_displayname, database_size);
+

Beschreibung

+

Die Methode erstellt eine neue SQL-Lite Datenbank und gibt ein Database -Objekt, das Manipulation der Daten ermöglicht.

+

Unterstützte Plattformen

+
    +
  • Android
  • +
  • BlackBerry WebWorks (OS 6.0 und höher)
  • +
  • iOS
  • +
  • Tizen
  • +
+

Kleines Beispiel

+
var db = window.openDatabase("test", "1.0", "Test DB", 1000000);
+

Vollständiges Beispiel

+
<!DOCTYPE html>
+<html>
+  <head>
+    <title>Storage Example</title>
+
+    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
+    <script type="text/javascript" charset="utf-8">
+
+    // Wait for device API libraries to load
+    //
+    document.addEventListener("deviceready", onDeviceReady, false);
+
+    // device APIs are available
+    //
+    function onDeviceReady() {
+        var db = window.openDatabase("test", "1.0", "Test DB", 1000000);
+    }
+
+    </script>
+  </head>
+  <body>
+    <h1>Example</h1>
+    <p>Open Database</p>
+  </body>
+</html>
+
+
+
+ + + + + + Added: cordova/site/public/docs/en/edge/guide_appdev_hooks_index.md.html URL: http://svn.apache.org/viewvc/cordova/site/public/docs/en/edge/guide_appdev_hooks_index.md.html?rev=1682113&view=auto ============================================================================== --- cordova/site/public/docs/en/edge/guide_appdev_hooks_index.md.html (added) +++ cordova/site/public/docs/en/edge/guide_appdev_hooks_index.md.html Wed May 27 20:06:53 2015 @@ -0,0 +1,368 @@ + + + + + + + + + + Apache Cordova API Documentation + + + + + + + +
+

Hooks Guide

+ +
+ + + +
+
+

Hooks Guide

+

Cordova Hooks represent special scripts which could be added by application and +plugin developers or even by your own build system to customize cordova commands. +Hook scripts could be defined by adding them to the special predefined folder +(/hooks) or via configuration files (config.xml and plugin.xml) and run +serially in the following order:

+
    +
  • Application hooks from /hooks;
  • +
  • Application hooks from config.xml;
  • +
  • Plugin hooks from plugins/.../plugin.xml.
  • +
+

Note: /hooks directory is considered deprecated in favor of the hook elements +in config.xml and plugin.xml.

+

Supported hook types

+

The following hook types are supported:

+
after_build
+after_compile
+after_docs
+after_emulate
+after_platform_add
+after_platform_rm
+after_platform_ls
+after_plugin_add
+after_plugin_ls
+after_plugin_rm
+after_plugin_search
+after_plugin_install // Plugin hooks in plugin.xml are executed for a plugin being installed only
+after_prepare
+after_run
+after_serve
+before_build
+before_compile
+before_docs
+before_emulate
+before_platform_add
+before_platform_rm/
+before_platform_ls
+before_plugin_add
+before_plugin_ls
+before_plugin_rm
+before_plugin_search/
+before_plugin_install // Plugin hooks in plugin.xml are executed for a plugin being installed only
+before_plugin_uninstall // Plugin hooks in plugin.xml are executed for a plugin being uninstalled only
+before_prepare
+before_run
+before_serve
+pre_package // Windows and Windows Phone only
+

Ways to define hooks

+

Via /hooks directory

+

Note: this method is considered deprecated in favor of the hook elements in config.xml and plugin.xml.

+

To execute custom action when corresponding hook type is fired, use hook type as a name for a subfolder inside 'hooks' directory and place you script file here, for example:

+
# script file will be automatically executed after each build
+hooks/after_build/after_build_custom_action.js
+

When using these hooks, they will always be run as executable files, not as loadable JavaScript modules. +Remember: Make your scripts executable in this case.

+

Config.xml

+

Hooks can be defined in project's config.xml using <hook> elements, for example:

+
<hook type="before_build" src="scripts/appBeforeBuild.bat" />
+<hook type="before_build" src="scripts/appBeforeBuild.js" />
+<hook type="before_plugin_install" src="scripts/appBeforePluginInstall.js" />
+
+<platform name="wp8">
+    <hook type="before_build" src="scripts/wp8/appWP8BeforeBuild.bat" />
+    <hook type="before_build" src="scripts/wp8/appWP8BeforeBuild.js" />
+    <hook type="before_plugin_install" src="scripts/wp8/appWP8BeforePluginInstall.js" />
+    ...
+</platform>
+
+<platform name="windows8">
+    <hook type="before_build" src="scripts/windows8/appWin8BeforeBuild.bat" />
+    <hook type="before_build" src="scripts/windows8/appWin8BeforeBuild.js" />
+    <hook type="before_plugin_install" src="scripts/windows8/appWin8BeforePluginInstall.js" />
+    ...
+</platform>
+

Plugin hooks (plugin.xml)

+

As a plugin developer you can define hook scripts using <hook> elements in a plugin.xml like that:

+
<hook type="before_plugin_install" src="scripts/beforeInstall.js" />
+<hook type="after_build" src="scripts/afterBuild.js" />
+
+<platform name="wp8">
+    <hook type="before_plugin_install" src="scripts/wp8BeforeInstall.js" />
+    <hook type="before_build" src="scripts/wp8BeforeBuild.js" />
+    ...
+</platform>
+

before_plugin_install, after_plugin_install, before_plugin_uninstall plugin hooks will be fired exclusively for the plugin being installed/uninstalled.

+

Script Interface

+

Javascript

+

If you are writing hooks using Node.js you should use the following module definition:

+
module.exports = function(context) {
+    ...
+}
+
+

You can make your scipts async using Q:

+
module.exports = function(context) {
+    var Q = context.requireCordovaModule('q');
+    var deferral = new Q.defer();
+
+    setTimeout(function(){
+      console.log('hook.js>> end');
+    deferral.resolve();
+    }, 1000);
+
+    return deferral.promise;
+}
+
+

context object contains hook type, executed script full path, hook options, command-line arguments passed to Cordova and top-level "cordova" object:

+
{
+  "hook": "before_plugin_install",
+  "scriptLocation": "c:\\script\\full\\path\\appBeforePluginInstall.js",
+  "cmdLine": "The\\exact\\command\\cordova\\run\\with arguments",
+  "opts": {
+    "projectRoot":"C:\\path\\to\\the\\project",
+    "cordova": {
+      "platforms": ["wp8"],
+      "plugins": ["com.plugin.withhooks"],
+      "version": "0.21.7-dev"
+    },
+    "plugin": {
+      "id": "com.plugin.withhooks",
+      "pluginInfo": {
+        ...
+      },
+      "platform": "wp8",
+      "dir": "C:\\path\\to\\the\\project\\plugins\\com.plugin.withhooks"
+    }
+  },
+  "cordova": {...}
+}
+
+

context.opts.plugin object will only be passed to plugin hooks scripts.

+

You can also require additional Cordova modules in your script using context.requireCordovaModule in the following way:

+
var Q = context.requireCordovaModule('q');
+
+

Note: new module loader script interface is used for the .js files defined via config.xml or plugin.xml only. +For compatibility reasons hook files specified via /hooks folders are run via Node child_process spawn, see 'Non-javascript' section below.

+

Non-javascript

+

Note: we highly recommend writing your hooks using Node.js so that they are cross-platform, see 'Javascript' section above.

+

Non-javascript scripts are run via Node child_process spawn from the project's root directory and have the root directory passes as the first argument. All other options are passed to the script using environment variables:

+
    +
  • CORDOVA_VERSION - The version of the Cordova-CLI.
  • +
  • CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios).
  • +
  • CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer)
  • +
  • CORDOVA_HOOK - Path to the hook that is being executed.
  • +
  • CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate)
  • +
+

If a script returns a non-zero exit code, then the parent cordova command will be aborted.

+

Also, note that even if you are working on Windows, and in case your hook scripts aren't bat files (which is recommended, if you want your scripts to work in non-Windows operating systems) Cordova CLI will expect a shebang line as the first line for it to know the interpreter it needs to use to launch the script. The shebang line should match the following example:

+
#!/usr/bin/env [name_of_interpreter_executable]
+

Sample Usage

+

This sample demonstrates Cordova hooks usage to trace to the console output the +size of generated .apk file for Android platform.

+

Create blank Cordova app and add the following definition to config.xml to +tell Cordova to run afterBuild.js script after each platform build.

+
<hook type="after_build" src="scripts/afterBuild.js" />
+

Create scripts/afterBuild.js file and add the following implementation. +We use async version of fs.stat method to demonstrate how async functionality +could be done via hooks.

+
module.exports = function(ctx) {
+    // make sure android platform is part of build 
+    if (ctx.opts.platforms.indexOf('android') < 0) {
+        return;
+    }
+    var fs = ctx.requireCordovaModule('fs'),
+        path = ctx.requireCordovaModule('path'),
+        deferral = ctx.requireCordovaModule('q').defer();
+
+    var platformRoot = path.join(ctx.opts.projectRoot, 'platforms/android');
+    var apkFileLocation = path.join(platformRoot, 'build/outputs/apk/android-debug.apk');
+
+    fs.stat(apkFileLocation, function(err,stats) {
+        if (err) {
+             deferral.reject('Operation failed');
+        } else {
+            console.log('Size of ' + apkFileLocation + ' is ' + stats.size +' bytes');
+            deferral.resolve();
+        }
+    });
+
+    return deferral.promise;
+};
+

Parameter ctx in example above is passed by Cordova and represents execution +context such as script full path, target platform, command-line arguments, etc and +also exposes additional helper functionality. See Script Interface section above +for more details.

+

You can now add android platform and execute build.

+
cordova platform add android
+..
+cordova build
+..
+Size of path\to\app\platforms\android\build\outputs\apk\android-debug.apk is 1821193 bytes
+

More good usage examples could be found here:

+

http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/

+ +
+
+ + + + + + Added: cordova/site/public/docs/en/edge/guide_platforms_win8_packaging.md.html URL: http://svn.apache.org/viewvc/cordova/site/public/docs/en/edge/guide_platforms_win8_packaging.md.html?rev=1682113&view=auto ============================================================================== --- cordova/site/public/docs/en/edge/guide_platforms_win8_packaging.md.html (added) +++ cordova/site/public/docs/en/edge/guide_platforms_win8_packaging.md.html Wed May 27 20:06:53 2015 @@ -0,0 +1,210 @@ + + + + + + + + + + Apache Cordova API Documentation + + + + + + + +
+

Packaging of Windows Store Apps

+ +
+ + + +
+
+

Packaging of Windows Store Apps

+

You can learn more about signing and packaging of Windows Store Apps on MSDN.aspx).

+

To be able to correctly package and sign Windows apps there are few things required:

+
    +
  • A signing certificate
  • +
  • Identity details matching the provided signing certificate
  • +
+

In Windows project, identity details are kept in a file named package.appxmanifest. This file is automatically populated every time a Cordova app is built. Identity holds 3 important fields.

+
    +
  • Name
  • +
  • Publisher
  • +
  • Version
  • +
+

Name and Version can be set from config.xml. Publisher can be provided as a build parameter or can be set on build.json file.

+

+

A signing certificate can be provided from either CLI or through build.json file. The certificate related CLI flags are:

+
    +
  • --packageCertificateKeyFile : Once a package signing certificate is created, this parameter can be used to associate the certificate with the app. This flag takes a file path as an argument. Eg. > cordova build -- --packageCertificateKeyFile="platforms\windows\CordovaApp_TemporaryKey.pfx"
  • +
  • --packageThumbprint : Package thumbprint is used to validate the authenticity of package certificate key file. When creating a certificate key file, this value will be provided to the end user. Eg. > cordova build -- --packageCertificateKeyFile="platforms\windows\CordovaApp_TemporaryKey.pfx" --packageThumbprint="ABCABCABCABC123123123123"
  • +
+

Alternatively, these values could be specified using a build configuration file (build.json) using CLI (--buildConfig). A sample build configuration file:

+
{
+    "windows": {
+        "debug": {
+            "packageCertificateKeyFile": "platforms\\windows\\CordovaApp_TemporaryKey.pfx"
+        },
+        "release": {
+            "packageCertificateKeyFile": "c:\\path-to-key\\keycert.pfx",
+            "packageThumbprint": "ABCABCABCABC123123123123",
+            "publisherId": "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
+        }
+    }
+}
+

There is also support to mix and match command line arguments and parameters in build.json file. Values from the command line arguments will get precedence.

+ +
+
+ + + + + + --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org