2017-03-08 19:08:52 +00:00
|
|
|
###
|
2018-10-19 14:38:50 +00:00
|
|
|
Copyright 2016-2017 Balena
|
2017-03-08 19:08:52 +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.
|
|
|
|
###
|
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
# Loads '.balena-sync.yml' configuration from 'source' directory.
|
2017-03-08 19:08:52 +00:00
|
|
|
# Returns the configuration object on success
|
|
|
|
#
|
|
|
|
|
2017-03-21 09:06:05 +00:00
|
|
|
_ = require('lodash')
|
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
balenaPush = require('balena-sync').capitano('balena-toolbox')
|
2019-04-02 17:01:28 +00:00
|
|
|
originalAction = balenaPush.action
|
2017-03-08 19:08:52 +00:00
|
|
|
|
|
|
|
# TODO: This is a temporary workaround to reuse the existing `rdt push`
|
2018-10-19 14:38:50 +00:00
|
|
|
# capitano frontend in `balena local push`.
|
2017-03-21 09:06:05 +00:00
|
|
|
|
2019-04-13 00:42:13 +00:00
|
|
|
# coffeelint: disable-next-line ("Line ends with trailing whitespace")
|
2019-04-02 17:01:28 +00:00
|
|
|
deprecationMsg = '''
|
2019-04-13 00:42:13 +00:00
|
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2019-04-02 17:01:28 +00:00
|
|
|
Deprecation notice: `balena local push` is deprecated and will be removed in a
|
2019-04-13 00:42:13 +00:00
|
|
|
future release of the CLI. Please use `balena push <ipAddress>` instead.
|
|
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2017-03-21 09:06:05 +00:00
|
|
|
|
2019-04-02 17:01:28 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
balenaPushHelp = """#{deprecationMsg}
|
|
|
|
Use this command to push your local changes to a container on a LAN-accessible
|
|
|
|
balenaOS device on the fly.
|
|
|
|
|
|
|
|
This command requires an openssh-compatible 'ssh' client and 'rsync' to be
|
|
|
|
available in the executable PATH of the shell environment. For more information
|
|
|
|
(including Windows support) please check the README at:
|
|
|
|
https://github.com/balena-io/balena-cli
|
2017-03-21 09:06:05 +00:00
|
|
|
|
|
|
|
If `Dockerfile` or any file in the 'build-triggers' list is changed,
|
|
|
|
a new container will be built and run on your device.
|
|
|
|
If not, changes will simply be synced with `rsync` into the application container.
|
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
After every 'balena local push' the updated settings will be saved in
|
|
|
|
'<source>/.balena-sync.yml' and will be used in later invocations. You can
|
|
|
|
also change any option by editing '.balena-sync.yml' directly.
|
2017-03-21 09:06:05 +00:00
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
Here is an example '.balena-sync.yml' :
|
2017-03-21 09:06:05 +00:00
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
$ cat $PWD/.balena-sync.yml
|
|
|
|
local_balenaos:
|
2018-07-31 19:46:07 +00:00
|
|
|
app-name: local-app
|
|
|
|
build-triggers:
|
2018-08-09 09:20:05 +00:00
|
|
|
- Dockerfile: file-hash-abcdefabcdefabcdefabcdefabcdefabcdef
|
|
|
|
- package.json: file-hash-abcdefabcdefabcdefabcdefabcdefabcdef
|
2018-07-31 19:46:07 +00:00
|
|
|
environment:
|
|
|
|
- MY_VARIABLE=123
|
|
|
|
|
2017-03-21 09:06:05 +00:00
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
Command line options have precedence over the ones saved in '.balena-sync.yml'.
|
2017-03-21 09:06:05 +00:00
|
|
|
|
|
|
|
If '.gitignore' is found in the source directory then all explicitly listed files will be
|
|
|
|
excluded when using rsync to update the container. You can choose to change this default behavior with the
|
|
|
|
'--skip-gitignore' option.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
$ balena local push
|
|
|
|
$ balena local push --app-name test-server --build-triggers package.json,requirements.txt
|
|
|
|
$ balena local push --force-build
|
|
|
|
$ balena local push --force-build --skip-logs
|
|
|
|
$ balena local push --ignore lib/
|
|
|
|
$ balena local push --verbose false
|
|
|
|
$ balena local push 192.168.2.10 --source . --destination /usr/src/app
|
|
|
|
$ balena local push 192.168.2.10 -s /home/user/balenaProject -d /usr/src/app --before 'echo Hello' --after 'echo Done'
|
2019-04-02 17:01:28 +00:00
|
|
|
"""
|
|
|
|
|
2017-03-21 09:06:05 +00:00
|
|
|
|
|
|
|
|
2018-10-19 14:38:50 +00:00
|
|
|
module.exports = _.assign balenaPush,
|
2017-03-21 09:06:05 +00:00
|
|
|
signature: 'local push [deviceIp]'
|
2019-04-02 17:01:28 +00:00
|
|
|
description: '[deprecated: use "balena push ipAddress"] ' + balenaPush.description
|
2018-10-19 14:38:50 +00:00
|
|
|
help: balenaPushHelp
|
2019-04-02 17:01:28 +00:00
|
|
|
primary: false
|
2017-03-21 09:06:05 +00:00
|
|
|
root: true
|
2019-04-02 17:01:28 +00:00
|
|
|
action: (params, options, done) ->
|
|
|
|
console.log deprecationMsg
|
|
|
|
originalAction(params, options, done)
|