<commit_before>'use strict';

var node_path   = require('path');
var node_url    = require('url');
var fs          = require('fs-sync');
var pkg_helper  = require('../util/package');

exports.shorthands = {
    c: 'cwd',
};

exports.options = {
    cwd: {
        type: node_path,
        default: process.cwd(),
        info: 'specify the current working directory.'
    },

    force: {
        type: Boolean,
        info: 'if `true`, cortex will force to publishing existing module.'
    },

    tar: {
        type: node_path,
        info: 'the tar file to publish, if specified, option `cwd` will be overriden',
        setter: function(tar) {
            var remain = this.get('remain') || [];
            var cwd = this.get('cwd');
            var done = this.async();

            if(!tar){
                if(remain.length){
                    tar = remain[0];
                }
            }

            if(!tar){
                // `if options.tar` is not specified, `options.cwd` must be the root of a repo 
                var dir = pkg_helper.repo_root(cwd);

                if(dir === null){
                    return done('directory "' + cwd + '" is not inside a project.');
                }

                return done(null);
            }

            if(!fs.isPathAbsolute(tar)){
                tar = node_path.resolve(cwd, tar);
            }

            if(!fs.isFile(tar)){
                return done('error `tar` parameter: `tar` does not exist or is not a file.');
            }

            done(null, tar);
        }
    },

    snapshot: {
        type: Boolean,
        info: 'if `true`, cortex will publish the current package as a snapshot version.',
        setter: function (snapshot) {
            if ( snapshot ) {
                // temporarily use --snapshot as an alias of --force
                this.set('force', true);
            }

            return false;
        }
    }
};

exports.info = 'Publish a module to npm server';

exports.usage = [
    '{{name}} publish [options]',
    '{{name}} publish <tarfile> [options]'
];<commit_msg>#161: option/publish: remove temporary code<commit_after>'use strict';

var node_path   = require('path');
var node_url    = require('url');
var fs          = require('fs-sync');
var pkg_helper  = require('../util/package');

exports.shorthands = {
    c: 'cwd',
};

exports.options = {
    cwd: {
        type: node_path,
        default: process.cwd(),
        info: 'specify the current working directory.'
    },

    force: {
        type: Boolean,
        info: 'if `true`, cortex will force to publishing existing module.'
    },

    tar: {
        type: node_path,
        info: 'the tar file to publish, if specified, option `cwd` will be overriden',
        setter: function(tar) {
            var remain = this.get('remain') || [];
            var cwd = this.get('cwd');
            var done = this.async();

            if(!tar){
                if(remain.length){
                    tar = remain[0];
                }
            }

            if(!tar){
                // `if options.tar` is not specified, `options.cwd` must be the root of a repo 
                var dir = pkg_helper.repo_root(cwd);

                if(dir === null){
                    return done('directory "' + cwd + '" is not inside a project.');
                }

                return done(null);
            }

            if(!fs.isPathAbsolute(tar)){
                tar = node_path.resolve(cwd, tar);
            }

            if(!fs.isFile(tar)){
                return done('error `tar` parameter: `tar` does not exist or is not a file.');
            }

            done(null, tar);
        }
    },

    snapshot: {
        type: Boolean,
        info: 'if `true`, cortex will publish the current package as a snapshot version.'
    }
};

exports.info = 'Publish a module to npm server';

exports.usage = [
    '{{name}} publish [options]',
    '{{name}} publish <tarfile> [options]'
];
{'fraction_non_alphanumeric': 0.13366834170854272, 'fraction_numerical': 0.001256281407035176, 'mean_word_length': 1.5683870967741935, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6161799', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1108, 'n_words': 327}