Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data:download command to download resources #565

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ Use `sfcc-ci --help` or just `sfcc-ci` to get started and see the full list of c
client:rotate [options] Rotate credentials of an Oauth client
client:delete [options] Delete an Oauth client
data:upload [options] Uploads a file onto a Commerce Cloud instance
data:download [options] Downloads a file from a Commerce Cloud instance
sandbox:realm:list [options] List realms eligible to manage sandboxes for
sandbox:realm:update [options] Update realm settings
sandbox:list [options] List all available sandboxes
Expand Down
13 changes: 13 additions & 0 deletions bin/test-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,19 @@ else
exit 1
fi

###############################################################################
###### Testing ´sfcc-ci data:download
###############################################################################

echo "Testing command ´sfcc-ci data:download´:"
node ./cli.js data:download --instance $ARG_HOST --path impex/src/instance/site_import.zip --target ./test/cli/site_import.zip
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi

###############################################################################
###### Testing ´sfcc-ci instance:export´
###############################################################################
Expand Down
44 changes: 44 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,50 @@ program
console.log();
});

program
.command('data:download')
.option('-i, --instance <instance>','Instance to download the file from. Can be an ' +
'instance alias. If not specified the currently configured instance will be used.')
.option('-p, --path <path>', 'The path of the file (WebDAV) to download')
.option('-t, --target <target>', 'The local file path where to store the file')
.option('-o, --overrideLocalFile <overrideLocalFile>', 'Override existing local file')
.description('Downloads a file from a Commerce Cloud instance')
.action(function(options) {
var instance = require('./lib/instance').getInstance(options.instance);
var path = ( options.path ? options.path : null );
if (!path) {
this.missingArgument('path');
return;
}
var target = ( options.target ? options.target : null );
if (!target) {
this.missingArgument('target');
return;
}
require('./lib/webdav').cli.download(instance, '/' + path, require('./lib/auth').getToken(), target, {
overrideLocalFile: options.overrideLocalFile
});
}).on('--help', function() {
console.log('');
console.log(' Details:');
console.log();
console.log(' Downloads file from an instance WebDAV folder into target local folder.');
console.log(' Although, there is no defined maximum size for downloaded files. You may want');
console.log(' to zip or gzip the file you want to download.');
console.log();
console.log(' The provided --path <path> is relative to /webdav/Sites/, e.g. "impex/src/myfile.zip".');
console.log();
console.log(' Supported top level --path are "impex", "static", "catalogs", "libraries" and "dynamic".');
console.log(' In order to use "catalogs", "libraries" and "dynamic" you have to set API permissions for');
console.log(' a specific catalog, library or dynamic folder in WebDAV Client Permissions.');
console.log();
console.log(' Examples:');
console.log();
console.log(' $ sfcc-ci data:download --instance my-instance.demandware.net ' +
'--path impex/src/instance/myfile.zip --target myfile.zip');
console.log();
});

program
.command('sandbox:realm:list')
.description('List realms eligible to manage sandboxes for')
Expand Down
3 changes: 2 additions & 1 deletion lib/webdav.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,5 +326,6 @@ module.exports.api = {
}
}
module.exports.cli = {
upload : upload
upload : upload,
download : downloadFile
};
Loading