2016-01-04 03:58:51 +00:00
|
|
|
###
|
2018-10-19 14:38:50 +00:00
|
|
|
Copyright 2016-2017 Balena
|
2016-01-04 03:58:51 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
###
|
|
|
|
|
2015-05-07 15:40:12 +00:00
|
|
|
exports.wizard =
|
|
|
|
signature: 'quickstart [name]'
|
2018-10-19 14:38:50 +00:00
|
|
|
description: 'getting started with balena'
|
2015-05-07 15:40:12 +00:00
|
|
|
help: '''
|
2018-10-19 14:38:50 +00:00
|
|
|
Use this command to run a friendly wizard to get started with balena.
|
2015-05-07 15:40:12 +00:00
|
|
|
|
|
|
|
The wizard will guide you through:
|
|
|
|
|
|
|
|
- Create an application.
|
2018-10-19 14:38:50 +00:00
|
|
|
- Initialise an SDCard with the balena operating system.
|
|
|
|
- Associate an existing project directory with your balena application.
|
2015-05-07 15:40:12 +00:00
|
|
|
- Push your project to your devices.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
$ balena quickstart
|
|
|
|
$ balena quickstart MyApp
|
2015-05-07 15:40:12 +00:00
|
|
|
'''
|
2015-10-01 14:39:36 +00:00
|
|
|
primary: true
|
2015-05-07 15:40:12 +00:00
|
|
|
action: (params, options, done) ->
|
2018-10-19 14:38:50 +00:00
|
|
|
balena = require('balena-sdk').fromSharedOptions()
|
2015-12-07 14:32:24 +00:00
|
|
|
patterns = require('../utils/patterns')
|
2018-05-22 15:12:51 +00:00
|
|
|
{ runCommand } = require('../utils/helpers')
|
2015-12-07 14:32:24 +00:00
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
balena.auth.isLoggedIn().then (isLoggedIn) ->
|
2016-01-12 14:12:04 +00:00
|
|
|
return if isLoggedIn
|
|
|
|
console.info('Looks like you\'re not logged in yet!')
|
2018-05-22 15:12:51 +00:00
|
|
|
console.info("Let's go through a quick wizard to get you started.\n")
|
|
|
|
return runCommand('login')
|
2016-01-12 14:12:04 +00:00
|
|
|
.then ->
|
2015-08-27 14:01:33 +00:00
|
|
|
return if params.name?
|
2015-09-29 15:10:33 +00:00
|
|
|
patterns.selectOrCreateApplication().tap (applicationName) ->
|
2018-10-19 14:38:50 +00:00
|
|
|
balena.models.application.has(applicationName).then (hasApplication) ->
|
2015-09-11 15:30:30 +00:00
|
|
|
return applicationName if hasApplication
|
2018-05-22 15:12:51 +00:00
|
|
|
runCommand("app create #{applicationName}")
|
2015-08-27 14:01:33 +00:00
|
|
|
.then (applicationName) ->
|
|
|
|
params.name = applicationName
|
|
|
|
.then ->
|
2018-05-22 15:12:51 +00:00
|
|
|
return runCommand("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) ->
|
2018-05-22 15:12:51 +00:00
|
|
|
return runCommand("device #{uuid}")
|
2015-08-27 14:01:33 +00:00
|
|
|
.then ->
|
2018-10-19 14:38:50 +00:00
|
|
|
return balena.models.application.get(params.name)
|
2015-12-02 20:28:32 +00:00
|
|
|
.then (application) ->
|
|
|
|
console.log """
|
|
|
|
Your device is ready to start pushing some code!
|
|
|
|
|
|
|
|
Check our official documentation for more information:
|
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
http://balena.io/docs/#/pages/introduction/introduction.md
|
2015-12-02 20:28:32 +00:00
|
|
|
|
|
|
|
Clone an example or go to an existing application directory and run:
|
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
$ git remote add balena #{application.git_repository}
|
|
|
|
$ git push balena master
|
2015-12-02 20:28:32 +00:00
|
|
|
"""
|
2015-08-27 14:01:33 +00:00
|
|
|
.nodeify(done)
|