From b3aa3d35f7932ba84cfa2d79d546b056187d83f9 Mon Sep 17 00:00:00 2001 From: Eugene Mirotin Date: Tue, 21 Mar 2017 12:06:05 +0300 Subject: [PATCH] fix resin local push help message and lint errors --- .editorconfig | 6 ++- build/actions/local/push.js | 21 +++++---- gulpfile.coffee | 4 +- lib/actions/local/push.coffee | 80 +++++++++++++++++++---------------- package.json | 6 ++- 5 files changed, 64 insertions(+), 53 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9e32b416..30a43b72 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,4 +9,8 @@ trim_trailing_whitespace = true insert_final_newline = true [*.md] -trim_trailing_whitespace = false \ No newline at end of file +trim_trailing_whitespace = false + +[package.json] +indent_style = space +indent_size = 2 diff --git a/build/actions/local/push.js b/build/actions/local/push.js index 9b75e350..63e5ca91 100644 --- a/build/actions/local/push.js +++ b/build/actions/local/push.js @@ -17,20 +17,19 @@ limitations under the License. */ (function() { - var resinPush; + var _, resinPush, resinPushHelp; + + _ = require('lodash'); resinPush = require('resin-sync').capitano('resin-toolbox'); - resinPush.signature = 'local push [deviceIp]'; + resinPushHelp = 'Warning: \'resin local push\' requires an openssh-compatible client and \'rsync\' to\nbe correctly installed in your shell environment. For more information (including\nWindows support) please check the README here: https://github.com/resin-io/resin-cli\n\nUse this command to push your local changes to a container on a LAN-accessible resinOS device on the fly.\n\nIf `Dockerfile` or any file in the \'build-triggers\' list is changed,\na new container will be built and run on your device.\nIf not, changes will simply be synced with `rsync` into the application container.\n\nAfter every \'resin local push\' the updated settings will be saved in\n\'/.resin-sync.yml\' and will be used in later invocations. You can\nalso change any option by editing \'.resin-sync.yml\' directly.\n\nHere is an example \'.resin-sync.yml\' :\n\n $ cat $PWD/.resin-sync.yml\n destination: \'/usr/src/app\'\n before: \'echo Hello\'\n after: \'echo Done\'\n ignore:\n - .git\n - node_modules/\n\nCommand line options have precedence over the ones saved in \'.resin-sync.yml\'.\n\nIf \'.gitignore\' is found in the source directory then all explicitly listed files will be\nexcluded when using rsync to update the container. You can choose to change this default behavior with the\n\'--skip-gitignore\' option.\n\nExamples:\n\n $ resin local push\n $ resin local push --app-name test-server --build-triggers package.json,requirements.txt\n $ resin local push --force-build\n $ resin local push --force-build --skip-logs\n $ resin local push --ignore lib/\n $ resin local push --verbose false\n $ resin local push 192.168.2.10 --source . --destination /usr/src/app\n $ resin local push 192.168.2.10 -s /home/user/myResinProject -d /usr/src/app --before \'echo Hello\' --after \'echo Done\''; - resinPush.help = { - help: 'Warning: \'resin local push\' requires an openssh-compatible client and \'rsync\' to\nbe correctly installed in your shell environment. For more information (including\nWindows support) please check the README here: https://github.com/resin-io/resin-cli\n\nUse this command to push your local changes to a container on a LAN-accessible resinOS device on the fly.\n\nIf `Dockerfile` or any file in the \'build-triggers\' list is changed, a new container will be built and run on your device.\nIf not, changes will simply be synced with `rsync` into the application container.\n\nAfter every \'resin local push\' the updated settings will be saved in\n\'/.resin-sync.yml\' and will be used in later invocations. You can\nalso change any option by editing \'.resin-sync.yml\' directly.\n\nHere is an example \'.resin-sync.yml\' :\n\n $ cat $PWD/.resin-sync.yml\n destination: \'/usr/src/app\'\n before: \'echo Hello\'\n after: \'echo Done\'\n ignore:\n - .git\n - node_modules/\n\nCommand line options have precedence over the ones saved in \'.resin-sync.yml\'.\n\nIf \'.gitignore\' is found in the source directory then all explicitly listed files will be\nexcluded when using rsync to update the container. You can choose to change this default behavior with the\n\'--skip-gitignore\' option.\n\nExamples:\n\n $ resin local push\n $ resin local push --app-name test-server --build-triggers package.json,requirements.txt\n $ resin local push --force-build\n $ resin local push --force-build --skip-logs\n $ resin local push --ignore lib/\n $ resin local push --verbose false\n $ resin local push 192.168.2.10 --source . --destination /usr/src/app\n $ resin local push 192.168.2.10 -s /home/user/myResinProject -d /usr/src/app --before \'echo Hello\' --after \'echo Done\'' - }; - - resinPush.primary = true; - - resinPush.root = true; - - module.exports = resinPush; + module.exports = _.assign(resinPush, { + signature: 'local push [deviceIp]', + help: resinPushHelp, + primary: true, + root: true + }); }).call(this); diff --git a/gulpfile.coffee b/gulpfile.coffee index 803b2e41..5b2d856d 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -30,5 +30,5 @@ gulp.task 'build', [ 'coffee' ] -gulp.task 'watch', [ 'lint', 'coffee' ], -> - gulp.watch([ OPTIONS.files.coffee ], [ 'coffee' ]) +gulp.task 'watch', [ 'build' ], -> + gulp.watch([ OPTIONS.files.coffee ], [ 'build' ]) diff --git a/lib/actions/local/push.coffee b/lib/actions/local/push.coffee index 9217d2ad..5aedb29b 100644 --- a/lib/actions/local/push.coffee +++ b/lib/actions/local/push.coffee @@ -18,53 +18,59 @@ limitations under the License. # Returns the configuration object on success # +_ = require('lodash') + resinPush = require('resin-sync').capitano('resin-toolbox') # TODO: This is a temporary workaround to reuse the existing `rdt push` # capitano frontend in `resin local push`. -resinPush.signature = 'local push [deviceIp]' -resinPush.help = - help: ''' - Warning: 'resin local push' requires an openssh-compatible client and 'rsync' to - be correctly installed in your shell environment. For more information (including - Windows support) please check the README here: https://github.com/resin-io/resin-cli - Use this command to push your local changes to a container on a LAN-accessible resinOS device on the fly. +resinPushHelp = ''' + Warning: 'resin local push' requires an openssh-compatible client and 'rsync' to + be correctly installed in your shell environment. For more information (including + Windows support) please check the README here: https://github.com/resin-io/resin-cli - 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. + Use this command to push your local changes to a container on a LAN-accessible resinOS device on the fly. - After every 'resin local push' the updated settings will be saved in - '/.resin-sync.yml' and will be used in later invocations. You can - also change any option by editing '.resin-sync.yml' directly. + 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. - Here is an example '.resin-sync.yml' : + After every 'resin local push' the updated settings will be saved in + '/.resin-sync.yml' and will be used in later invocations. You can + also change any option by editing '.resin-sync.yml' directly. - $ cat $PWD/.resin-sync.yml - destination: '/usr/src/app' - before: 'echo Hello' - after: 'echo Done' - ignore: - - .git - - node_modules/ + Here is an example '.resin-sync.yml' : - Command line options have precedence over the ones saved in '.resin-sync.yml'. + $ cat $PWD/.resin-sync.yml + destination: '/usr/src/app' + before: 'echo Hello' + after: 'echo Done' + ignore: + - .git + - node_modules/ - 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. + Command line options have precedence over the ones saved in '.resin-sync.yml'. - Examples: + 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. - $ resin local push - $ resin local push --app-name test-server --build-triggers package.json,requirements.txt - $ resin local push --force-build - $ resin local push --force-build --skip-logs - $ resin local push --ignore lib/ - $ resin local push --verbose false - $ resin local push 192.168.2.10 --source . --destination /usr/src/app - $ resin local push 192.168.2.10 -s /home/user/myResinProject -d /usr/src/app --before 'echo Hello' --after 'echo Done' - ''' -resinPush.primary = true -resinPush.root = true -module.exports = resinPush + Examples: + + $ resin local push + $ resin local push --app-name test-server --build-triggers package.json,requirements.txt + $ resin local push --force-build + $ resin local push --force-build --skip-logs + $ resin local push --ignore lib/ + $ resin local push --verbose false + $ resin local push 192.168.2.10 --source . --destination /usr/src/app + $ resin local push 192.168.2.10 -s /home/user/myResinProject -d /usr/src/app --before 'echo Hello' --after 'echo Done' +''' + + +module.exports = _.assign resinPush, + signature: 'local push [deviceIp]' + help: resinPushHelp + primary: true + root: true diff --git a/package.json b/package.json index d6ccfd77..eee49da3 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,10 @@ }, "scripts": { "build": "gulp build", - "prepublish": "npm run build", - "doc": "mkdir -p doc/ && coffee extras/capitanodoc/index.coffee > doc/cli.markdown" + "doc": "mkdir -p doc/ && coffee extras/capitanodoc/index.coffee > doc/cli.markdown", + "watch": "gulp watch", + "lint": "gulp lint", + "prepublish": "npm run build && npm run doc" }, "keywords": [ "resin",