Merge pull request #416 from resin-io/support-aufs-resin-sync

Support aufs resin sync
This commit is contained in:
Kostas Lekkas 2017-02-21 15:03:59 +02:00 committed by GitHub
commit 9214cb0d90
3 changed files with 3 additions and 269 deletions

View File

@ -17,125 +17,6 @@ limitations under the License.
*/
(function() {
var loadConfig;
loadConfig = function(source) {
var _, config, configPath, error, fs, jsYaml, path, result;
fs = require('fs');
path = require('path');
_ = require('lodash');
jsYaml = require('js-yaml');
configPath = path.join(source, '.resin-sync.yml');
try {
config = fs.readFileSync(configPath, {
encoding: 'utf8'
});
result = jsYaml.safeLoad(config);
} catch (error1) {
error = error1;
if (error.code === 'ENOENT') {
return {};
}
throw error;
}
if (!_.isPlainObject(result)) {
throw new Error("Invalid configuration file: " + configPath);
}
return result;
};
module.exports = {
signature: 'sync [uuid]',
description: '(beta) sync your changes to a device',
help: 'Warning: \'resin sync\' 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 sync your local changes to a certain device on the fly.\n\nAfter every \'resin sync\' the updated settings will be saved in\n\'<source>/.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 uuid: 7cf02a6\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 from the syncing process. You can choose to change this default behavior with the\n\'--skip-gitignore\' option.\n\nExamples:\n\n $ resin sync 7cf02a6 --source . --destination /usr/src/app\n $ resin sync 7cf02a6 -s /home/user/myResinProject -d /usr/src/app --before \'echo Hello\' --after \'echo Done\'\n $ resin sync --ignore lib/\n $ resin sync --verbose false\n $ resin sync',
permission: 'user',
primary: true,
options: [
{
signature: 'source',
parameter: 'path',
description: 'local directory path to synchronize to device',
alias: 's'
}, {
signature: 'destination',
parameter: 'path',
description: 'destination path on device',
alias: 'd'
}, {
signature: 'ignore',
parameter: 'paths',
description: 'comma delimited paths to ignore when syncing',
alias: 'i'
}, {
signature: 'skip-gitignore',
boolean: true,
description: 'do not parse excluded/included files from .gitignore'
}, {
signature: 'before',
parameter: 'command',
description: 'execute a command before syncing',
alias: 'b'
}, {
signature: 'after',
parameter: 'command',
description: 'execute a command after syncing',
alias: 'a'
}, {
signature: 'port',
parameter: 'port',
description: 'ssh port',
alias: 't'
}, {
signature: 'progress',
boolean: true,
description: 'show progress',
alias: 'p'
}, {
signature: 'verbose',
boolean: true,
description: 'increase verbosity',
alias: 'v'
}
],
action: function(params, options, done) {
var Promise, fs, path, patterns, resin, resinSync;
fs = require('fs');
path = require('path');
resin = require('resin-sdk-preconfigured');
Promise = require('bluebird');
resinSync = require('resin-sync');
patterns = require('../utils/patterns');
return Promise["try"](function() {
try {
fs.accessSync(path.join(process.cwd(), '.resin-sync.yml'));
} catch (error1) {
if (options.source == null) {
throw new Error('No --source option passed and no \'.resin-sync.yml\' file found in current directory.');
}
}
if (options.source == null) {
options.source = process.cwd();
}
if (options.ignore != null) {
options.ignore = options.ignore.split(',');
}
return Promise.resolve(params.uuid).then(function(uuid) {
var savedUuid;
if (uuid == null) {
savedUuid = loadConfig(options.source).uuid;
return patterns.inferOrSelectDevice(savedUuid);
}
return resin.models.device.has(uuid).then(function(hasDevice) {
if (!hasDevice) {
throw new Error("Device not found: " + uuid);
}
return uuid;
});
}).then(function(uuid) {
return resinSync.sync(uuid, options);
});
}).nodeify(done);
}
};
module.exports = require('resin-sync').capitano('resin-cli');
}).call(this);

View File

@ -14,151 +14,4 @@ See the License for the specific language governing permissions and
limitations under the License.
###
# Loads '.resin-sync.yml' configuration from 'source' directory.
# Returns the configuration object on success
#
# TODO: Use 'config.load()' method from `resin sync` when resin sync gets
# integrated into resin CLI
loadConfig = (source) ->
fs = require('fs')
path = require('path')
_ = require('lodash')
jsYaml = require('js-yaml')
configPath = path.join(source, '.resin-sync.yml')
try
config = fs.readFileSync(configPath, encoding: 'utf8')
result = jsYaml.safeLoad(config)
catch error
# return empty object if '.resin-sync.yml' is missing
if error.code is 'ENOENT'
return {}
throw error
if not _.isPlainObject(result)
throw new Error("Invalid configuration file: #{configPath}")
return result
module.exports =
signature: 'sync [uuid]'
description: '(beta) sync your changes to a device'
help: '''
Warning: 'resin sync' 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 sync your local changes to a certain device on the fly.
After every 'resin sync' the updated settings will be saved in
'<source>/.resin-sync.yml' and will be used in later invocations. You can
also change any option by editing '.resin-sync.yml' directly.
Here is an example '.resin-sync.yml' :
$ cat $PWD/.resin-sync.yml
uuid: 7cf02a6
destination: '/usr/src/app'
before: 'echo Hello'
after: 'echo Done'
ignore:
- .git
- node_modules/
Command line options have precedence over the ones saved in '.resin-sync.yml'.
If '.gitignore' is found in the source directory then all explicitly listed files will be
excluded from the syncing process. You can choose to change this default behavior with the
'--skip-gitignore' option.
Examples:
$ resin sync 7cf02a6 --source . --destination /usr/src/app
$ resin sync 7cf02a6 -s /home/user/myResinProject -d /usr/src/app --before 'echo Hello' --after 'echo Done'
$ resin sync --ignore lib/
$ resin sync --verbose false
$ resin sync
'''
permission: 'user'
primary: true
options: [
signature: 'source'
parameter: 'path'
description: 'local directory path to synchronize to device'
alias: 's'
,
signature: 'destination'
parameter: 'path'
description: 'destination path on device'
alias: 'd'
,
signature: 'ignore'
parameter: 'paths'
description: 'comma delimited paths to ignore when syncing'
alias: 'i'
,
signature: 'skip-gitignore'
boolean: true
description: 'do not parse excluded/included files from .gitignore'
,
signature: 'before'
parameter: 'command'
description: 'execute a command before syncing'
alias: 'b'
,
signature: 'after'
parameter: 'command'
description: 'execute a command after syncing'
alias: 'a'
,
signature: 'port'
parameter: 'port'
description: 'ssh port'
alias: 't'
,
signature: 'progress'
boolean: true
description: 'show progress'
alias: 'p'
,
signature: 'verbose'
boolean: true
description: 'increase verbosity'
alias: 'v'
,
]
action: (params, options, done) ->
fs = require('fs')
path = require('path')
resin = require('resin-sdk-preconfigured')
Promise = require('bluebird')
resinSync = require('resin-sync')
patterns = require('../utils/patterns')
Promise.try ->
try
fs.accessSync(path.join(process.cwd(), '.resin-sync.yml'))
catch
if not options.source?
throw new Error('No --source option passed and no \'.resin-sync.yml\' file found in current directory.')
options.source ?= process.cwd()
# TODO: Add comma separated options to Capitano
if options.ignore?
options.ignore = options.ignore.split(',')
Promise.resolve(params.uuid)
.then (uuid) ->
if not uuid?
savedUuid = loadConfig(options.source).uuid
return patterns.inferOrSelectDevice(savedUuid)
resin.models.device.has(uuid)
.then (hasDevice) ->
if not hasDevice
throw new Error("Device not found: #{uuid}")
return uuid
.then (uuid) ->
resinSync.sync(uuid, options)
.nodeify(done)
module.exports = require('resin-sync').capitano('resin-cli')

View File

@ -55,7 +55,7 @@
"resin-image-manager": "^4.0.0",
"resin-sdk-preconfigured": "^0.1.0",
"resin-settings-client": "^3.5.0",
"resin-sync": "^2.0.2",
"resin-sync": "^6.1.0",
"rimraf": "^2.4.3",
"rindle": "^1.0.0",
"tmp": "^0.0.31",