2015-05-07 15:40:12 +00:00
|
|
|
Promise = require('bluebird')
|
|
|
|
capitano = Promise.promisifyAll(require('capitano'))
|
2015-08-27 14:01:33 +00:00
|
|
|
mkdirp = Promise.promisify(require('mkdirp'))
|
2015-05-07 15:40:12 +00:00
|
|
|
resin = require('resin-sdk')
|
|
|
|
form = require('resin-cli-form')
|
2015-08-20 19:54:42 +00:00
|
|
|
patterns = require('../utils/patterns')
|
2015-05-07 15:40:12 +00:00
|
|
|
|
|
|
|
exports.wizard =
|
|
|
|
signature: 'quickstart [name]'
|
|
|
|
description: 'getting started with resin.io'
|
|
|
|
help: '''
|
|
|
|
Use this command to run a friendly wizard to get started with resin.io.
|
|
|
|
|
|
|
|
The wizard will guide you through:
|
|
|
|
|
|
|
|
- Create an application.
|
|
|
|
- Initialise an SDCard with the resin.io operating system.
|
|
|
|
- Associate an existing project directory with your resin.io application.
|
|
|
|
- Push your project to your devices.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
$ sudo resin quickstart
|
|
|
|
$ sudo resin quickstart MyApp
|
|
|
|
'''
|
|
|
|
root: true
|
|
|
|
permission: 'user'
|
|
|
|
action: (params, options, done) ->
|
2015-08-27 14:01:33 +00:00
|
|
|
Promise.try ->
|
|
|
|
return if params.name?
|
2015-08-20 19:54:42 +00:00
|
|
|
patterns.selectApplication().tap (applicationName) ->
|
2015-09-11 15:30:30 +00:00
|
|
|
resin.models.application.has(applicationName).then (hasApplication) ->
|
|
|
|
return applicationName if hasApplication
|
|
|
|
capitano.runAsync("app create #{applicationName}")
|
2015-08-27 14:01:33 +00:00
|
|
|
.then (applicationName) ->
|
|
|
|
params.name = applicationName
|
|
|
|
.then ->
|
|
|
|
return capitano.runAsync("device init --application #{params.name}")
|
2015-08-20 19:54:42 +00:00
|
|
|
.tap(patterns.awaitDevice)
|
2015-08-27 14:01:33 +00:00
|
|
|
.then (uuid) ->
|
|
|
|
return capitano.runAsync("device #{uuid}")
|
|
|
|
.tap ->
|
|
|
|
console.log('Your device is ready, lets start pushing some code!')
|
2015-08-20 19:54:42 +00:00
|
|
|
.then(patterns.selectProjectDirectory)
|
2015-08-27 14:01:33 +00:00
|
|
|
.tap(mkdirp)
|
|
|
|
.tap(process.chdir)
|
|
|
|
.then ->
|
|
|
|
return capitano.runAsync("app associate #{params.name}")
|
|
|
|
.then (remoteUrl) ->
|
|
|
|
console.log("Resin git remote added: #{remoteUrl}")
|
|
|
|
console.log """
|
|
|
|
Please type:
|
|
|
|
|
|
|
|
$ cd #{process.cwd()} && git push resin master
|
|
|
|
|
|
|
|
To push your project to resin.io.
|
|
|
|
"""
|
|
|
|
.nodeify(done)
|