Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[CB-606] Added create script for unix and windows
  • Loading branch information
filmaj committed Jun 13, 2012
1 parent 245c2c6 commit 5f3fbff20666f11ef5bf4de71acec1860e60078a
Show file tree
Hide file tree
Showing 109 changed files with 13,568 additions and 12 deletions.
@@ -4,8 +4,6 @@

# Eclipse

bin/
build/
deliverables/
.preprocessed/

@@ -23,4 +21,3 @@ dist/
.DS_Store

tags

@@ -9,7 +9,7 @@ Directory Structure
framework/ ... BlackBerry WebWorks JavaScript Extension (Cordova native code)
javascript/ .. Cordova JavaScript (Non-concatenated, non-minified)
lib/ ......... Third party tools
template/ .... Project template for creating a new projects
bin/ ......... Scripts for project creation

Introduction
------------
@@ -18,13 +18,13 @@ BlackBerry WebWorks is a framework for developing web-based applications for Bla

The WebWorks framework allows developers to create applications using web content and resources (HTML/CSS/JavaScript) that are able to access device features through the [Blackberry WebWorks API](http://www.blackberry.com/developers/docs/widgetapi/). In addition, the framework allows developers to create their own WebWorks JavaScript Extensions to expose additional device capabilities through JavaScript APIs. These extensions are written using either the BlackBerry Java API for SmartPhones, or Adobe AIR for the Tablet OS.

The cordova-blackberry-webworks platform allows web developers to develop applications targeting BlackBerry 5.0 and higher devices using the common [Cordova API](http://docs.phonegap.com). When possible, Cordova makes use of the WebWorks JavaScript API; however, most Cordova features are implemented in the native Java environment as a WebWorks JavaScript Extension.
The cordova-blackberry-webworks platform allows web developers to develop applications targeting BlackBerry 5.0 and higher devices using the common [Cordova API](http://docs.phonegap.com). When possible, Cordova makes use of the WebWorks JavaScript API; however, most Cordova features are implemented in the native Java or AIR environment as a WebWorks JavaScript Extension.


Getting Started
===============

Several guides are available on the [Cordova Wiki](http://wiki.phonegap.com) to help you get started developing for the cordova-blackberry-webworks platform. This guide will help you install and configure the BlackBerry WebWorks development environment, and the cordova-blackberry-webworks platform. It will also step you through the process of creating a Cordova project.
Several guides are available on the [Cordova Wiki](http://wiki.phonegap.com) and on the [PhoneGap Documentation site](http://docs.phonegap.com/) (Getting Started Guides - on the left side near the bottom) to help you get started developing for the cordova-blackberry-webworks platform. This guide will help you install and configure the BlackBerry WebWorks development environment, and the cordova-blackberry-webworks platform. It will also step you through the process of creating a Cordova project.

[Getting Started with Cordova BlackBerry WebWorks](http://wiki.phonegap.com/w/page/31930982/Getting-Started-with-PhoneGap-BlackBerry-WebWorks)

@@ -43,13 +43,75 @@ Cloning the cordova-blackberry-webworks repository always provides you with the

As an alternative, you can download packaged releases of Cordova from the [PhoneGap web site](http://phonegap.com). If choosing this method, simply unzip the Cordova packaged code and navigate to the BlackBerry/WebWorks directory. The steps below remain the same.

Cordova BlackBerry Developer Tools
---

Creating a New Cordova Project
The Cordova developer tooling is split between general tooling and project level tooling.

To enable the command-line tools available in the ./bin directory, make
sure you have all of the dependencies installed. You will need
[NodeJS](http://nodejs.org) (which should come with `npm`). To install
the dependencies:

$ cd bin
$ npm install

General Commands

./bin/create [path appname] ............ creates a sample app with the specified application name, to the specified path
./bin/bench ............................ generate a bench proj
./bin/autotest ......................... test the cli tools
./bin/test ............................. run mobile-spec

Please note that once you `create` a Cordova BlackBerry project, you
will need to edit the `project.properties` file that resides inside your
generated application directory to set up your environment properly. You
will need to specify things like the location of the BlackBerry Widget
Packager(s), device and signing key passwords, simulator executables,
and device IPs (if applicable).

TODO: Project Commands

These commands live in a generated Cordova BlackBerry project. NOTE: not
available yet.

./cordova/debug [path] ..................... install to first device
./cordova/emulate .......................... start avd (emulator) named default
./cordova/log .............................. starts logcat

Running the Example Project (TODO)
---

Start a simulator:

./bin/emulate

Create the example project and build it to the first device:

./bin/create
cd example
./cordova/debug

Start streaming a log from the device

./cordova/log

Running the [mobile-spec](http://github.com/apache/incubator-cordova-mobile-spec) tests:
---

./bin/test

Creating a new Cordova BlackBerry Project
---

./bin/create ~/Desktop/myapp MyApp

(Legacy) Creating a New Cordova Project
-------------------------------

The Cordova build script enables you to create multiple, independent Cordova projects.
The (legacy) Cordova ant build scripts enable you to create multiple, independent Cordova projects.

(Note: The Cordova build script requries Apache ANT 1.8 or higher. See the [Getting Started guide](http://wiki.phonegap.com/w/page/31930982/Getting-Started-with-PhoneGap-BlackBerry-WebWorks) for instructions on how to install and configure Apache ANT).
(Note: The Cordova build script requires Apache ANT 1.8 or higher. See the [Getting Started guide](http://wiki.phonegap.com/w/page/31930982/Getting-Started-with-PhoneGap-BlackBerry-WebWorks) for instructions on how to install and configure Apache ANT).

The build script packages the Cordova source code and resources into each project you create. This allows you to easily distribute the project to other BlackBerry WebWorks developers. To create a Cordova project:

@@ -0,0 +1,21 @@
#! /bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
./bin/create
cd ./example && ./cordova/debug && ./cordova/log
@@ -0,0 +1,2 @@
#! /usr/bin/env node
require('nodeunit').reporters.default.run(['bin/tests'])
@@ -0,0 +1,47 @@
#! /bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
#
# Creates an app in `./bench` that posts results to http://cordova-bench.heroku.com with current cordova/Android sha.
#
# USAGE
# ./bin/bench
#

# clobber any existing bench
if [ -e ./bench ]
then
rm -rf ./bench
fi

# create a benching app
./bin/create ./bench cordovaBench

# grab the latest bench www code
git clone git@github.com:brianleroux/cordova-bench.git

# copy it into the app
cat ./cordova-bench/www/index.html > ./bench/assets/www/index.html
#cat ~/Desktop/cordova-bench/www/index.html > ./bench/assets/www/index.html

# clean up
rm -rf ./cordova-bench

# launch to the first device found
./bin/debug ./bench
@@ -0,0 +1,77 @@
#! /bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# create a cordova/android project
#
# USAGE
# ./create [path appname]
#
set -e

if [ -n "$1" ] && [ "$1" == "-h" ]
then
echo 'usage: create path appname'
echo 'After you have created your application, make sure to customize the project.properties file inside your app directory with your environment specifics!'
exit 0
fi

BUILD_PATH=$( cd "$( dirname "$0" )/.." && pwd )
VERSION=$(cat $BUILD_PATH/VERSION)

PROJECT_PATH=${1:-"./example"}
APPNAME=${2:-"cordovaExample"}

# clobber any existing example
if [ -d $PROJECT_PATH ]
then
echo "Project already exists! Delete and recreate"
exit 1
fi

# cleanup after exit and/or on error
function on_exit {
echo "Cleaning up ..."
[ -d $BUILD_PATH/build ] && rm -rf $BUILD_PATH/build
[ -d $BUILD_PATH/dist ] && rm -rf $BUILD_PATH/dist
echo "Remember to update the project.properties file inside your application directory!"
}

function on_error {
echo "An error occured. Deleting project..."
[ -d $PROJECT_PATH ] && rm -rf $PROJECT_PATH
}

# we do not want the script to silently fail
trap on_error ERR
trap on_exit EXIT

ANT=$(which ant)

MANIFEST_PATH=$PROJECT_PATH/www/config.xml

# compile cordova.js and cordova.jar
echo "Building cordova-$VERSION.jar and cordova-$VERSION.js ..."
(cd $BUILD_PATH && $ANT dist &> /dev/null )

# copy project template
echo "Copying assets and resources ..."
cp -r $BUILD_PATH/dist/sample/. $PROJECT_PATH

# interpolate the app name into config.xml
echo "Updating config.xml ..."
sed -i '' -e "s/__NAME__/${APPNAME}/g" $MANIFEST_PATH
@@ -0,0 +1,14 @@
@ECHO OFF
IF NOT DEFINED JAVA_HOME GOTO MISSING
FOR %%X in (ant.bat) do (
SET FOUND=%%~$PATH:X
IF NOT DEFINED FOUND GOTO MISSING
)
cscript %~dp0\create.js %*
GOTO END
:MISSING
ECHO Missing one of the following:
ECHO JDK: http://java.oracle.com
ECHO Apache ant: http://ant.apache.org
EXIT /B 1
:END
@@ -0,0 +1,90 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

/*
* create a cordova/android project
*
* USAGE
* ./create [path package activity]
*/

var fso = WScript.CreateObject('Scripting.FileSystemObject');

function read(filename) {
var fso=WScript.CreateObject("Scripting.FileSystemObject");
var f=fso.OpenTextFile(filename, 1);
var s=f.ReadAll();
f.Close();
return s;
}
function write(filename, contents) {
var fso=WScript.CreateObject("Scripting.FileSystemObject");
var f=fso.OpenTextFile(filename, 2, true);
f.Write(contents);
f.Close();
}
function replaceInFile(filename, regexp, replacement) {
write(filename, read(filename).replace(regexp, replacement));
}
function exec(s, output) {
var o=shell.Exec(s);
while (o.Status == 0) {
WScript.Sleep(100);
}
//WScript.Echo("Command exited with code " + o.Status);
}

function cleanup() {
// Cleanup
if(fso.FolderExists(ROOT + '\\dist')) {
fso.DeleteFolder(ROOT + '\\dist', true);
}
if(fso.FolderExists(ROOT + '\\build')) {
fso.DeleteFolder(ROOT + '\\build');
}
}

var args = WScript.Arguments, PROJECT_PATH="example",
APPNAME="cordovaExample",
shell=WScript.CreateObject("WScript.Shell");

// working dir
var ROOT = WScript.ScriptFullName.split('\\bin\\create.js').join('');

if (args.Count() == 2) {
PROJECT_PATH=args(0);
APPNAME=args(1);
}

if(fso.FolderExists(PROJECT_PATH)) {
WScript.Echo("Project directory already exists! Please remove it first.");
WScript.Quit(1);
}

var MANIFEST_PATH=PROJECT_PATH+'\\www\\config.xml';
var VERSION=read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');

exec('ant.bat -f '+ ROOT +'\\build.xml dist');

// copy in the project template
exec('cmd /c xcopy '+ ROOT + '\\dist\\sample\\* '+PROJECT_PATH+' /S /Y');

replaceInFile(MANIFEST_PATH, /__NAME__/, APPNAME);

cleanup();

0 comments on commit 5f3fbff

Please sign in to comment.