sardines-compile-time-tools
Version:
sardines.compile-time-tools.js is part of the sardines.io project
57 lines (56 loc) • 3.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var sardines_core_1 = require("sardines-core");
var index_1 = require("./index");
var proc = require("process");
var fs = require("fs");
var params = sardines_core_1.utils.parseArgs().params;
if (params.test) {
index_1.publish({});
}
if (params.help) {
console.log("\n --config : set the sardines config file, default is ./sardines-config.json\n --private : set the service as private, default is false\n --local=<path> : Service definition file path, default is './sardines-local-services.json'\n --patch : Increase patch number of version, default is true\n --minor : Increase minor number of version, default is false\n --major : Increase major number of version, default is false\n --version=<ver> : set the version number, format is 'major.minor.patch'\n --tag=<tag name> : set the additional git tag, must be used together with --tagMsg\n --tagMsg=<tag message> : set the tag/version message of git\n --commit=<commit message> : set the git commit message of this version\n --git-remote=<remote name>: select the git remote, default is 'origin'\n --git-branch=<branch name>: select the git branch to store version information, default is 'sardines'\n --verbose : verbose mode, log everything on the stdout\n ");
proc.exit(0);
}
var serviceDefinitionFile = params['local'] ? params['local'] : './sardines-local-services.json';
var sardinesConfigFile = params['config'] ? params['config'] : './sardines-config.json';
if (!fs.existsSync(serviceDefinitionFile)) {
console.error("Service definition file [" + serviceDefinitionFile + "] does not exist");
proc.exit(1);
}
if (!fs.lstatSync(serviceDefinitionFile).isFile()) {
console.error("Service definition file [" + serviceDefinitionFile + "] is not a valid file");
proc.exit(1);
}
var args = {
serviceDefinitionFile: serviceDefinitionFile,
sardinesConfigFile: sardinesConfigFile,
};
if (typeof params['major'] === 'boolean')
args.major = params['major'];
if (typeof params['minor'] === 'boolean')
args.minor = params['minor'];
if (typeof params['patch'] === 'boolean')
args.patch = params['patch'];
if (typeof params['version'] === 'string')
args.version = params['version'];
if (typeof params['tag'] === 'string')
args.tag = params['tag'];
if (typeof params['tagMsg'] === 'string')
args.tagMsg = params['tagMsg'];
if (typeof params['commit'] === 'string')
args.commit = params['commit'];
if (typeof params['git-remote'] === 'string')
args.remote = params['git-remote'];
if (typeof params['git-branch'] === 'string')
args.branch = params['git-branch'];
if (typeof params['verbose'] === 'boolean')
args.verbose = params['verbose'];
if (typeof params['private'] === 'boolean')
args.isPublic = !params['private'];
index_1.publish(args).then(function (res) {
console.log("successfully published " + res.length + " services");
}).catch(function (e) {
console.error("error when publishing:", e);
});