phonegap-build
Advanced tools
Comparing version
@@ -25,9 +25,9 @@ /* | ||
CLI.prototype.help = require('./cli/help'); | ||
CLI.prototype.login = require('./cli/login'); | ||
CLI.prototype.help.login = require('./cli/help/login'); | ||
CLI.prototype.help.create = require('./cli/help/create'); | ||
CLI.prototype.help.build = require('./cli/help/build'); | ||
CLI.prototype.login = require('./cli/login'); | ||
CLI.prototype.logout = require('./cli/logout'); | ||
CLI.prototype.create = require('./cli/create'); | ||
CLI.prototype.help.create = require('./cli/help/create'); | ||
CLI.prototype.build = require('./cli/build'); | ||
CLI.prototype.help.build = require('./cli/help/build'); | ||
@@ -34,0 +34,0 @@ /* |
@@ -10,3 +10,3 @@ /*! | ||
* | ||
* For now, forward to the original PhoneGap Build create. | ||
* Creates a PhoneGap project. | ||
* | ||
@@ -29,27 +29,18 @@ * Options: | ||
// require login before creating a project | ||
self.login(argv, function(e, api) { | ||
// project info | ||
var data = { | ||
path: argv._[1] | ||
}; | ||
// create the project | ||
self.phonegapbuild.create(data, function(e) { | ||
if (e) { | ||
callback(e); | ||
return; | ||
console.error('failed to create the project:', e.message); | ||
} | ||
else { | ||
console.log('created the project:', data.path); | ||
} | ||
// project info | ||
var data = { | ||
api: api, | ||
path: argv._[1] | ||
}; | ||
// create the project | ||
self.phonegapbuild.create(data, function(e) { | ||
if (e) { | ||
console.error('failed to create the project:', e.message); | ||
} | ||
else { | ||
console.log('created the project:', data.path); | ||
} | ||
callback(e); | ||
}); | ||
callback(e); | ||
}); | ||
}; |
@@ -44,3 +44,3 @@ /** | ||
' ' + argv.$0 + ' help create', | ||
' ' + argv.$0 + ' create path/to/my/app', | ||
' ' + argv.$0 + ' create path/to/my-app', | ||
'' | ||
@@ -47,0 +47,0 @@ ]; |
@@ -19,12 +19,7 @@ /** | ||
'', | ||
' Create a new application locally and remotely.', | ||
' Create a new application.', | ||
'', | ||
' Options:', | ||
'', | ||
' -n, --name your application name', | ||
'', | ||
' Examples:', | ||
'', | ||
' $ ' + argv.$0 + ' create ./my-app', | ||
' $ ' + argv.$0 + ' create ./my-app --name "My App"', | ||
'' | ||
@@ -31,0 +26,0 @@ ]; |
@@ -17,3 +17,2 @@ /*! | ||
* - `options` {Object} is data required to create an app | ||
* - `api` {Object} is a phonegap-build-rest API object. | ||
* - `path` {String} is a directory path for the app. | ||
@@ -33,3 +32,2 @@ * - [`callback`] {Function} is triggered after creating the app. | ||
if (!options) throw new Error('requires option parameter'); | ||
if (!options.api) throw new Error('requires option.api parameter'); | ||
if (!options.path) throw new Error('requires option.path parameter'); | ||
@@ -40,3 +38,3 @@ | ||
// validate path | ||
// expand path | ||
options.path = path.resolve(options.path); | ||
@@ -43,0 +41,0 @@ |
{ | ||
"name": "phonegap-build", | ||
"description": "PhoneGap Build command-line interface and node.js library.", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"homepage": "http://github.com/mwbrooks/phonegap-build-cli", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -30,80 +30,51 @@ /* | ||
describe('$ phonegap-build create ./my-app', function() { | ||
it('should try to login', function() { | ||
spyOn(cli, 'login'); | ||
it('should try to create the project', function() { | ||
cli.argv({ _: ['create', './my-app'] }); | ||
expect(cli.login).toHaveBeenCalled(); | ||
expect(cli.phonegapbuild.create).toHaveBeenCalledWith( | ||
{ | ||
path: jasmine.any(String) | ||
}, | ||
jasmine.any(Function) | ||
); | ||
}); | ||
describe('successful login', function() { | ||
describe('successful project creation', function() { | ||
beforeEach(function() { | ||
spyOn(cli, 'login').andCallFake(function(argv, callback) { | ||
callback(null, {}); | ||
cli.phonegapbuild.create.andCallFake(function(opts, callback) { | ||
callback(null); | ||
}); | ||
}); | ||
it('should try to create the project', function() { | ||
cli.argv({ _: ['create', './my-app'] }); | ||
expect(cli.phonegapbuild.create).toHaveBeenCalledWith( | ||
{ | ||
api: jasmine.any(Object), | ||
path: jasmine.any(String) | ||
}, | ||
jasmine.any(Function) | ||
); | ||
}); | ||
describe('successful project creation', function() { | ||
beforeEach(function() { | ||
cli.phonegapbuild.create.andCallFake(function(opts, callback) { | ||
callback(null); | ||
}); | ||
it('should call callback without an error', function(done) { | ||
cli.argv({ _: ['create', './my-app'] }, function(e) { | ||
expect(e).toBeNull(); | ||
done(); | ||
}); | ||
it('should call callback without an error', function(done) { | ||
cli.argv({ _: ['create', './my-app'] }, function(e) { | ||
expect(e).toBeNull(); | ||
done(); | ||
}); | ||
}); | ||
it('should output a message about the created project', function() { | ||
// @TODO | ||
}); | ||
}); | ||
describe('failed project creation', function() { | ||
beforeEach(function() { | ||
cli.phonegapbuild.create.andCallFake(function(opts, callback) { | ||
callback(new Error('Directory already exists')); | ||
}); | ||
it('should output a success message', function(done) { | ||
cli.argv({ _: ['create', './my-app'] }, function(e) { | ||
expect(process.stdout.write).toHaveBeenCalled(); | ||
done(); | ||
}); | ||
it('should call callback with an error', function(done) { | ||
cli.argv({ _: ['create', './my-app'] }, function(e) { | ||
expect(e).toEqual(jasmine.any(Error)); | ||
done(); | ||
}); | ||
}); | ||
it('should output a message about the uncreated project', function() { | ||
// @TODO | ||
}); | ||
}); | ||
}); | ||
describe('failed login', function() { | ||
describe('failed project creation', function() { | ||
beforeEach(function() { | ||
spyOn(cli, 'login').andCallFake(function(argv, callback) { | ||
callback(new Error('Invalid account')); | ||
cli.phonegapbuild.create.andCallFake(function(opts, callback) { | ||
callback(new Error('Directory already exists')); | ||
}); | ||
}); | ||
it('should not create the project', function() { | ||
cli.argv({ _: ['create', './my-app'] }); | ||
expect(cli.phonegapbuild.create).not.toHaveBeenCalled(); | ||
it('should call callback with an error', function(done) { | ||
cli.argv({ _: ['create', './my-app'] }, function(e) { | ||
expect(e).toEqual(jasmine.any(Error)); | ||
done(); | ||
}); | ||
}); | ||
it('should call callback with an error', function(done) { | ||
it('should output a message about the uncreated project', function(done) { | ||
cli.argv({ _: ['create', './my-app'] }, function(e) { | ||
expect(e).not.toBeNull(); | ||
expect(process.stdout.write).toHaveBeenCalled(); | ||
done(); | ||
@@ -110,0 +81,0 @@ }); |
@@ -33,9 +33,2 @@ /* | ||
it('should require options.api', function() { | ||
expect(function() { | ||
options.api = undefined; | ||
create(options, function(e) {}); | ||
}).toThrow(); | ||
}); | ||
it('should require options.path', function() { | ||
@@ -42,0 +35,0 @@ expect(function() { |
109
0.93%1537751
-0.07%7003
-0.33%