UNPKG

cloudcms-cli

Version:
84 lines (77 loc) 2.46 kB
var helper = require("../../../helper"); var AbstractCommand = require("../../abstract"); class ResyncCommand extends AbstractCommand { constructor() { super({ "group": "publishing", "name": "resync", "description": "Resyncs the publishing of one or more nodes", "schema": { "properties": [{ "name": "repositoryId", "type": "string", "description": "Enter the repository ID", "required": true, "args": ["repository", "r"] }, { "name": "branchId", "type": "string", "description": "Enter the branch ID", "required": true, "args": ["branch", "b"] }, { "name": "nodeId", "type": "string", "description": "Enter a node ID", "required": false, "args": ["node", "id"] }, { "name": "state", "type": "string", "description": "Enter a lifecycle state", "required": false, "args": ["state"] }, { "name": "config", "type": "string", "description": "Optional JSON configuration string", "required": false, "args": ["config"] }] } }); } handle(options, callback) { var nodeIds = []; if (Array.isArray(options.nodeId)) { for (var i = 0; i < options.nodeId.length; i++) { nodeIds.push(options.nodeId[i]); } } else { nodeIds.push(options.nodeId); } if (nodeIds.length === 0) { return callback({ "message": "Missing node IDs" }) } var json = null; if (options.config) { json = JSON.parse("" + options.config); } // call workhorse function helper.publishingResyncNodes(options.repositoryId, options.branchId, nodeIds, options.state, json,function(err) { callback(err); }); } } module.exports = ResyncCommand;