You can try following in your command js.
Extensions.YourExnName.prototype.isAvailable = function YourExnName$isAvailable(target)
{
//check here for publication
return true/false;;
};
Extensions.YourExnName.prototype.isEnabled = function YourExnName$isEnabled(target) {
//check here for publication
return true/false;
};