Skip to content
Permalink
Browse files
…ova-cli

Conflicts:
	package.json
  • Loading branch information
bshepherdson committed Jan 16, 2014
2 parents 293e281 + d3bb7d9 commit 40089a1e25fbe4c0825344cb14dbc1fc9af600a8
Show file tree
Hide file tree
Showing 28 changed files with 317 additions and 296 deletions.
@@ -1,2 +1,3 @@
temp
spec/fixtures
spec
e2e
@@ -130,23 +130,27 @@ Now the `cordova` and `plugman` in your path are the local git versions. Don't f
A Cordova application built with `cordova-cli` will have the following directory structure:

myApp/
|--.cordova/
|-- config.xml
|-- hooks/
|-- merges/
| | |-- android/
| | |-- blackberry10/
| | `-- ios/
|-- www/
| `-- config.xml
|-- platforms/
| |-- android/
| |-- blackberry10/
| `-- ios/
`-- plugins/
## .cordova/
This directory identifies a tree as a cordova project. Simple configuration information is stored in here (such as BlackBerry environment variables).
## hooks/
This directory may contains scripts used to customize cordova commands. This
directory used to exist at `.cordova/hooks`, but has now been moved to the
project root. Any scripts you add to these directories will be executed before
and after the commands corresponding to the directory name. Useful for
integrating your own build systems or integrating with version control systems.
Commands other than `create` operate against the project directory itself, rather than the current directory - a search up the current directory's parents is made to find this project directory. Thus, any command (other than `create`) can be used from any subdirectory whose parent is a cordova project directory (same as `git`).
Refer to [templates/hooks-README.md](templates/hooks-README.md) for more information.
## merges/
Platform-specific web assets (HTML, CSS and JavaScript files) are contained within appropriate subfolders in this directory. These are deployed during a `prepare` to the appropriate native directory. Files placed under `merges/` will override matching files in the `www/` folder for the relevant platform. A quick example, assuming a project structure of:
@@ -190,7 +194,7 @@ There are two types of hooks: project-specific ones and module-level ones. Both

## Project-specific Hooks

These are located under the `.cordova/hooks` directory in the root of your cordova project. Any scripts you add to these directories will be executed before and after the appropriate commands. Useful for integrating your own build systems or integrating with version control systems. __Remember__: make your scripts executable.
These are located under the `hooks` directory in the root of your cordova project. Any scripts you add to these directories will be executed before and after the appropriate commands. Useful for integrating your own build systems or integrating with version control systems. __Remember__: make your scripts executable.

### Examples

@@ -216,7 +220,7 @@ This example shows how to create a project from scratch named KewlApp with iOS a
The directory structure of KewlApp now looks like this:

KewlApp/
|-- .cordova/
|-- hooks/
|-- merges/
| |-- android/
| `-- ios/
@@ -20,6 +20,18 @@
-->
# Cordova-cli Release Notes

## 3.3.1-0.2.0 (Jan 15, 2014)
* CB-5006 Add --searchpath to "plugin add" so that installing by ID will search local paths before hitting the registry.
* CB-4153 Add --src & --link to cordova create.
* CB-5687 Make cordova commands work when CWD is inside of a symlink'ed www/
* CB-4910 Default config.xml to the root instead of within www/
* CB-5764 Move hooks/ to top-level instead of under .cordova
* CB-5763 Don't create .cordova/ by default
* CB-4871 Reduced package size significantly.
* CB-4976 Don't use ~/.cordova/lib for local directory
* CB-5777 Fix "platform update" not updating cordova.js
* CB-5728 Files in merges must remain intact when removing platform

## 3.3.0-0.1.0
* CB-5347 Handle dangling platform symlink in cordova platform add
* Added deprecation notice about wp7
@@ -190,3 +202,4 @@ Important note: This version targets Cordova version 3.1.0-rc1.

- Plugins are now installed serially across all installed platforms, rather than in parallel. This avoids race conditions in dependency installation. [CB-4184](https://issues.apache.org/jira/browse/CB-4184)
- (WP8) All files from project www dir are now copied into the binary, not the top-level www. This means merges and plugin assets are correctly handled.

@@ -17,7 +17,7 @@
under the License.
*/
var cordova_events = require('./src/events');
var addModuleProperty = require('./src/util').addModuleProperty;
var cordova_util = require('./src/util');

var off = function() {
cordova_events.removeListener.apply(cordova_events, arguments);
@@ -41,12 +41,16 @@ exports = module.exports = {
raw: {}
};

exports.findProjectRoot = function(opt_startDir) {
return cordova_util.isCordova(opt_startDir);
}

var addModuleProperty = cordova_util.addModuleProperty;
addModuleProperty(module, 'prepare', './src/prepare', true);
addModuleProperty(module, 'build', './src/build', true);
addModuleProperty(module, 'help', './src/help');
addModuleProperty(module, 'config', './src/config');
addModuleProperty(module, 'create', './src/create', true);
addModuleProperty(module, 'ripple', './src/ripple');
addModuleProperty(module, 'emulate', './src/emulate', true);
addModuleProperty(module, 'plugin', './src/plugin', true);
addModuleProperty(module, 'plugins', './src/plugin', true);
@@ -77,30 +77,16 @@ describe('create end-to-end', function() {

function checkProject() {
// Check if top level dirs exist.
var dirs = ['.cordova', 'platforms', 'merges', 'plugins', 'www'];
var dirs = ['hooks', 'platforms', 'merges', 'plugins', 'www'];
dirs.forEach(function(d) {
expect(path.join(project, d)).toExist();
});

// Check if hook dirs exist.
var hooksDir = path.join(project, '.cordova', 'hooks');
dirs = crossConcat(['platform', 'plugin'], ['add', 'rm', 'ls'], '_');
dirs = dirs.concat(['build', 'compile', 'docs', 'emulate', 'prepare', 'run']);
dirs = crossConcat(['before', 'after'], dirs, '_');
dirs.forEach(function(d) {
expect(path.join(hooksDir, d)).toExist();
});
expect(path.join(project, 'hooks', 'README.md')).toExist();

// Check if config files exist.
expect(path.join(cordovaDir, 'config.json')).toExist();
expect(path.join(project, 'www', 'config.xml')).toExist();
expect(path.join(project, 'www', 'index.html')).toExist();

// Check contents of config.json
var cfg = config.read(project);
expect(cfg.id).toEqual(appId);
expect(cfg.name).toEqual(appName);

// Check that www/config.xml was updated.
var configXml = new util.config_parser(path.join(project, 'www', 'config.xml'));
expect(configXml.packageName()).toEqual(appId);
@@ -37,7 +37,9 @@ var ext = platform.match(/(win32|win64)/)?'bat':'sh';


// copy fixture
shell.rm('-rf', tmpDir);
shell.rm('-rf', project);
shell.mkdir('-p', project);
shell.cp('-R', path.join(__dirname, 'fixtures', 'base', '*'), project);
shell.mkdir('-p', dotCordova);
shell.cp('-R', path.join(__dirname, 'fixtures', 'hooks_' + ext), dotCordova);
shell.mv(path.join(dotCordova, 'hooks_' + ext), hooksDir);
@@ -243,7 +245,7 @@ describe('hooks', function() {
it('should not fail during cleanup', function() {
process.chdir(path.join(__dirname, '..')); // Non e2e tests assume CWD is repo root.
if(ext == 'sh') {
shell.rm('-rf', tmpDir);
//shell.rm('-rf', tmpDir);
} else { // Windows:
// For some mysterious reason, both shell.rm and RMDIR /S /Q won't
// delete the dir on Windows, but they do remove the files leaving
@@ -19,11 +19,11 @@ describe('platform end-to-end', function() {
var results;

beforeEach(function() {
shell.rm('-rf', project);
shell.rm('-rf', tmpDir);
});
afterEach(function() {
process.chdir(path.join(__dirname, '..')); // Needed to rm the dir on Windows.
shell.rm('-rf', project);
shell.rm('-rf', tmpDir);
});

// Factoring out some repeated checks.
@@ -1,6 +1,6 @@
{
"name": "cordova",
"version": "3.3.1-0.1.2",
"version": "3.3.1-0.2.0",
"preferGlobal": "true",
"description": "Cordova command line interface tool",
"main": "cordova",
@@ -28,28 +28,19 @@
"cli"
],
"dependencies": {
"colors": ">=0.6.0",
"elementtree": "0.1.5",
"plugman": "0.17.x",
"plist": "0.4.x",
"plugman": "0.18.0",
"plist-with-patches": "0.5.x",
"xcode": "0.6.6",
"express": "3.0.0",
"shelljs": "0.1.2",
"ncallbacks": "1.0.0",
"request": "2.22.0",
"ripple-emulator": "0.9.18",
"semver": "1.1.0",
"glob": "3.2.x",
"follow-redirects": "0.0.x",
"prompt": "0.2.7",
"shelljs": "0.1.x",
"request": "~2.21.0",
"semver": "2.0.x",
"tar": "0.1.x",
"open": "0.0.3",
"npm": "1.3.x",
"npmconf": "0.1.x",
"q": "~0.9",
"optimist": "0.6.0",
"jshint": "~1.1.0",
"mime": "~1.2.11",
"lodash": "~2.4.0"
"underscore":"1.4.4"
},
"devDependencies": {
"jasmine-node": "1.8.x"
@@ -97,7 +97,7 @@ describe("cordova cli", function () {

it("will call command with all arguments passed through", function () {
new CLI(["node", "cordova", "plugin", "add", "facebook", "--variable", "FOO=foo"]);
expect(cordova.raw.plugin).toHaveBeenCalledWith("add", ["facebook", "--variable", "FOO=foo"]);
expect(cordova.raw.plugin).toHaveBeenCalledWith("add", ["facebook", "--variable", "FOO=foo"], {searchpath: undefined});
});
});
});
@@ -60,30 +60,6 @@ describe('create command', function () {
});

describe('success', function() {
it('should create a default project if only directory is specified', function(done) {
cordova.raw.create(tempDir).then(function() {
expect(mkdir).toHaveBeenCalledWith('-p', path.join(tempDir, '.cordova'));
expect(package).toHaveBeenCalledWith('io.cordova.hellocordova');
expect(name).toHaveBeenCalledWith('HelloCordova');
done();
});
});
it('should create a default project if only directory and id is specified', function(done) {
cordova.raw.create(tempDir, 'ca.filmaj.canucks').then(function() {
expect(mkdir).toHaveBeenCalledWith('-p', path.join(tempDir, '.cordova'));
expect(package).toHaveBeenCalledWith('ca.filmaj.canucks');
expect(name).toHaveBeenCalledWith('HelloCordova');
done();
});
});
it('should create a project in specified directory with specified name and id', function(done) {
cordova.raw.create(tempDir, 'ca.filmaj.canucks', 'IHateTheBruins').then(function() {
expect(mkdir).toHaveBeenCalledWith('-p', path.join(tempDir, '.cordova'));
expect(package).toHaveBeenCalledWith('ca.filmaj.canucks');
expect(name).toHaveBeenCalledWith('IHateTheBruins');
done();
});
});
it('should create top-level directory structure appropriate for a cordova-cli project', function(done) {
cordova.raw.create(tempDir).then(function() {
expect(mkdir).toHaveBeenCalledWith('-p', path.join(tempDir, 'platforms'));
@@ -93,34 +69,14 @@ describe('create command', function () {
done();
});
});
it('should create appropriate directories for hooks', function(done) {
var hooks_dir = path.join(tempDir, '.cordova', 'hooks');
it('should create hooks directory', function(done) {
var hooks_dir = path.join(tempDir, 'hooks');
cordova.raw.create(tempDir).then(function() {
expect(mkdir).toHaveBeenCalledWith('-p', hooks_dir);
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_build')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_compile')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_docs')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_emulate')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_platform_add')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_platform_rm')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_platform_ls')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_plugin_add')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_plugin_ls')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_plugin_rm')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_prepare')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'after_run')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_build')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_compile')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_docs')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_emulate')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_platform_add')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_platform_rm')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_platform_ls')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_plugin_add')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_plugin_ls')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_plugin_rm')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_prepare')));
expect(mkdir).toHaveBeenCalledWith( (path.join(hooks_dir, 'before_run')));
expect(cp).toHaveBeenCalledWith(
path.resolve(__dirname, '..', 'templates', 'hooks-README.md'),
jasmine.any(String)
);
done();
});
});
@@ -20,7 +20,7 @@ var lazy_load = require('../src/lazy_load'),
config = require('../src/config'),
util = require('../src/util'),
shell = require('shelljs'),
npm = require('npm');
npmconf = require('npmconf');
path = require('path'),
hooker = require('../src/hooker'),
request = require('request'),
@@ -83,6 +83,7 @@ describe('lazy_load module', function() {
});

describe('remote URLs for libraries', function() {
var npmConfProxy;
var req,
load_spy,
events = {},
@@ -94,6 +95,7 @@ describe('lazy_load module', function() {
pipe: jasmine.createSpy().andCallFake(function() { return fakeRequest; })
};
beforeEach(function() {
npmConfProxy = null;
events = {};
fakeRequest.on.reset();
fakeRequest.pipe.reset();
@@ -104,8 +106,7 @@ describe('lazy_load module', function() {
}, 10);
return fakeRequest;
});
load_spy = spyOn(npm, 'load').andCallFake(function(cb) { cb(); });
npm.config.get = function() { return null; };
load_spy = spyOn(npmconf, 'load').andCallFake(function(cb) { cb(null, { get: function() { return npmConfProxy }}); });
});

it('should call request with appopriate url params', function(done) {
@@ -120,7 +121,7 @@ describe('lazy_load module', function() {
});
it('should take into account https-proxy npm configuration var if exists for https:// calls', function(done) {
var proxy = 'https://somelocalproxy.com';
npm.config.get = function() { return proxy; };
npmConfProxy = proxy;
var url = 'https://github.com/apache/someplugin';
lazy_load.custom(url, 'random', 'android', '1.0').then(function() {
expect(req).toHaveBeenCalledWith({
@@ -133,7 +134,7 @@ describe('lazy_load module', function() {
});
it('should take into account proxy npm config var if exists for http:// calls', function(done) {
var proxy = 'http://somelocalproxy.com';
npm.config.get = function() { return proxy; };
npmConfProxy = proxy;
var url = 'http://github.com/apache/someplugin';
lazy_load.custom(url, 'random', 'android', '1.0').then(function() {
expect(req).toHaveBeenCalledWith({
@@ -26,7 +26,6 @@ var platforms = require('../../platforms'),
Q = require('q'),
child_process = require('child_process'),
config = require('../../src/config'),
prompt = require('prompt'),
config_parser = require('../../src/config_parser'),
cordova = require('../../cordova');

@@ -20,7 +20,7 @@ var platforms = require('../../platforms'),
util = require('../../src/util'),
path = require('path'),
shell = require('shelljs'),
plist = require('plist'),
plist = require('plist-with-patches'),
xcode = require('xcode'),
ET = require('elementtree'),
fs = require('fs'),
@@ -41,6 +41,7 @@ function fail(e) {
describe('platform command', function() {
var is_cordova,
cd_project_root,
cp,
list_platforms,
fire,
config_parser,
@@ -61,7 +62,8 @@ describe('platform command', function() {
beforeEach(function() {
supported_platforms.forEach(function(p) {
parsers[p] = spyOn(platforms[p], 'parser').andReturn({
staging_dir:function(){}
staging_dir:function(){},
www_dir:function(){return 'pwww'}
});
});
is_cordova = spyOn(util, 'isCordova').andReturn(project_dir);
@@ -94,6 +96,7 @@ describe('platform command', function() {
});

rm = spyOn(shell, 'rm');
cp = spyOn(shell, 'cp');
mkdir = spyOn(shell, 'mkdir');
existsSync = spyOn(fs, 'existsSync').andReturn(false);
var origReadFile = fs.readFileSync;

0 comments on commit 40089a1

Please sign in to comment.