Merge pull request #210 from resin-io/jviotti/feature/os-init-type

Make os initialize take a device type instead of a uuid
This commit is contained in:
Juan Cruz Viotti 2015-09-30 15:59:58 -04:00
commit ed6427c541
6 changed files with 14 additions and 16 deletions

View File

@ -148,7 +148,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 capitano.runAsync("os initialize " + temporalPath + " " + device.uuid);
return capitano.runAsync("os initialize " + temporalPath + " " + application.device_type);
});
});
}).then(function(device) {

View File

@ -98,13 +98,13 @@
};
exports.initialize = {
signature: 'os initialize <image> <uuid>',
signature: 'os initialize <image> <type>',
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 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9',
help: 'Use this command to initialize a previously configured operating system image.\n\nExamples:\n\n $ resin os initialize ../path/rpi.img \'raspberry-pi\'',
permission: 'user',
action: function(params, options, done) {
console.info('Initializing device');
return resin.models.device.get(params.uuid).get('device_type').then(resin.models.device.getManifestBySlug).then(function(manifest) {
return resin.models.device.getManifestBySlug(params.type).then(function(manifest) {
var ref;
return (ref = manifest.initialization) != null ? ref.options : void 0;
}).then(form.run).tap(function(answers) {
@ -115,7 +115,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.uuid, answers).then(stepHandler);
return init.initialize(params.image, params.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;uuid&#62;](#os-initialize-60-image-62-60-uuid-62-)
- [os initialize &#60;image&#62; &#60;type&#62;](#os-initialize-60-image-62-60-type-62-)
- Wizard
@ -550,13 +550,13 @@ Examples:
$ resin os configure ../path/rpi.img 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
## os initialize &#60;image&#62; &#60;uuid&#62;
## os initialize &#60;image&#62; &#60;type&#62;
Use this command to initialize a previously configured operating system image.
Examples:
$ resin os initialize ../path/rpi.img 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
$ resin os initialize ../path/rpi.img 'raspberry-pi'
# Wizard

View File

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

View File

@ -95,21 +95,19 @@ exports.configure =
.nodeify(done)
exports.initialize =
signature: 'os initialize <image> <uuid>'
signature: 'os initialize <image> <type>'
description: 'initialize an os image'
help: '''
Use this command to initialize a previously configured operating system image.
Examples:
$ resin os initialize ../path/rpi.img 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9
$ resin os initialize ../path/rpi.img 'raspberry-pi'
'''
permission: 'user'
action: (params, options, done) ->
console.info('Initializing device')
resin.models.device.get(params.uuid)
.get('device_type')
.then(resin.models.device.getManifestBySlug)
resin.models.device.getManifestBySlug(params.type)
.then (manifest) ->
return manifest.initialization?.options
.then(form.run)
@ -120,7 +118,7 @@ exports.initialize =
.return(answers.drive)
.then(umount.umountAsync)
.tap (answers) ->
return init.initialize(params.image, params.uuid, answers).then(stepHandler)
return init.initialize(params.image, params.type, answers).then(stepHandler)
.then (answers) ->
return if not answers.drive?
umount.umountAsync(answers.drive).tap ->

View File

@ -55,7 +55,7 @@
"resin-cli-visuals": "^1.2.2",
"resin-config-inject": "^2.0.0",
"resin-device-config": "^1.0.0",
"resin-device-init": "^1.0.4",
"resin-device-init": "^2.0.0",
"resin-image": "^1.1.4",
"resin-image-manager": "^3.2.2",
"resin-pine": "^1.3.0",