Merge pull request #229 from resin-io/jviotti/feature/os-initialize-type-option

Take device type as an option in os initialize
This commit is contained in:
Juan Cruz Viotti 2015-10-15 09:59:44 -04:00
commit b6ebd0631a
5 changed files with 42 additions and 13 deletions

View File

@ -154,7 +154,7 @@
return Promise.using(download(), function(temporalPath) {
return capitano.runAsync("device register " + application.app_name).then(resin.models.device.get).tap(function(device) {
return capitano.runAsync("os configure " + temporalPath + " " + device.uuid).then(function() {
return helpers.sudo(['os', 'initialize', temporalPath, application.device_type]);
return helpers.sudo(['os', 'initialize', temporalPath, '--type', application.device_type]);
});
});
}).then(function(device) {

View File

@ -100,12 +100,18 @@
};
exports.initialize = {
signature: 'os initialize <image> <type>',
signature: 'os initialize <image>',
description: 'initialize an os image',
help: 'Use this command to initialize a previously configured operating system image.\n\nExamples:\n\n $ resin os initialize ../path/rpi.img \'raspberry-pi\'',
help: 'Use this command to initialize a previously configured operating system image.\n\nExamples:\n\n $ resin os initialize ../path/rpi.img --type \'raspberry-pi\'',
permission: 'user',
options: [
commandOptions.yes, {
signature: 'type',
description: 'device type',
parameter: 'type',
alias: 't',
required: 'You have to specify a device type'
}, {
signature: 'drive',
description: 'drive',
parameter: 'drive',
@ -115,7 +121,7 @@
root: true,
action: function(params, options, done) {
console.info('Initializing device');
return resin.models.device.getManifestBySlug(params.type).then(function(manifest) {
return resin.models.device.getManifestBySlug(options.type).then(function(manifest) {
var ref;
return (ref = manifest.initialization) != null ? ref.options : void 0;
}).then(function(questions) {
@ -132,7 +138,7 @@
message = "This will erase " + answers.drive + ". Are you sure?";
return patterns.confirm(options.yes, message)["return"](answers.drive).then(umount.umountAsync);
}).tap(function(answers) {
return init.initialize(params.image, params.type, answers).then(stepHandler);
return init.initialize(params.image, options.type, answers).then(stepHandler);
}).then(function(answers) {
if (answers.drive == null) {
return;

View File

@ -74,7 +74,7 @@ Now you have access to all the commands referenced below.
- [os download &#60;type&#62;](#os-download-60-type-62-)
- [os configure &#60;image&#62; &#60;uuid&#62;](#os-configure-60-image-62-60-uuid-62-)
- [os initialize &#60;image&#62; &#60;type&#62;](#os-initialize-60-image-62-60-type-62-)
- [os initialize &#60;image&#62;](#os-initialize-60-image-62-)
- Wizard
@ -426,6 +426,12 @@ Examples:
$ resin help apps
$ resin help os download
### Options
#### --verbose, -v
show additional commands
# Information
## version
@ -550,13 +556,23 @@ Examples:
$ resin os configure ../path/rpi.img 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
## os initialize &#60;image&#62; &#60;type&#62;
## os initialize &#60;image&#62;
Use this command to initialize a previously configured operating system image.
Examples:
$ resin os initialize ../path/rpi.img 'raspberry-pi'
$ resin os initialize ../path/rpi.img --type 'raspberry-pi'
### Options
#### --yes, -y
confirm non interactively
#### --type, -t &#60;type&#62;
device type
# Wizard

View File

@ -211,7 +211,7 @@ exports.init =
.then(resin.models.device.get)
.tap (device) ->
capitano.runAsync("os configure #{temporalPath} #{device.uuid}").then ->
helpers.sudo([ 'os', 'initialize', temporalPath, application.device_type ])
helpers.sudo([ 'os', 'initialize', temporalPath, '--type', application.device_type ])
.then (device) ->
console.log('Done')
return device.uuid

View File

@ -96,18 +96,25 @@ exports.configure =
.nodeify(done)
exports.initialize =
signature: 'os initialize <image> <type>'
signature: 'os initialize <image>'
description: 'initialize an os image'
help: '''
Use this command to initialize a previously configured operating system image.
Examples:
$ resin os initialize ../path/rpi.img 'raspberry-pi'
$ resin os initialize ../path/rpi.img --type 'raspberry-pi'
'''
permission: 'user'
options: [
commandOptions.yes
{
signature: 'type'
description: 'device type'
parameter: 'type'
alias: 't'
required: 'You have to specify a device type'
}
{
signature: 'drive'
description: 'drive'
@ -118,7 +125,7 @@ exports.initialize =
root: true
action: (params, options, done) ->
console.info('Initializing device')
resin.models.device.getManifestBySlug(params.type)
resin.models.device.getManifestBySlug(options.type)
.then (manifest) ->
return manifest.initialization?.options
.then (questions) ->
@ -132,7 +139,7 @@ exports.initialize =
.return(answers.drive)
.then(umount.umountAsync)
.tap (answers) ->
return init.initialize(params.image, params.type, answers).then(stepHandler)
return init.initialize(params.image, options.type, answers).then(stepHandler)
.then (answers) ->
return if not answers.drive?
umount.umountAsync(answers.drive).tap ->