UNPKG

jesse

Version:

An advanced cryptocurrency trading framework for TypeScript

66 lines 2.52 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(require("path")); const commander_1 = __importDefault(require("commander")); const commands_1 = __importDefault(require("./commands")); const did_you_mean_1 = __importDefault(require("did-you-mean")); const findup_sync_1 = __importDefault(require("findup-sync")); const nodeModulesPath = findup_sync_1.default('node_modules'); let packageJson = null; try { packageJson = require(`${nodeModulesPath}/../package.json`); } catch (error) { } process.env.jesse_path = process.cwd(); process.env.jesse_vendor_path = `${nodeModulesPath}/jesse`; process.env.node_modules_path = nodeModulesPath; if (packageJson && packageJson.jessePath) { process.env.jesse_path = path_1.default.join(`${nodeModulesPath}/../`, packageJson.jessePath); } commander_1.default .option('--force', 'Forces a command') .version(require('../package').version) .usage('<command> [options]'); commander_1.default .command('init') .description('Initially creates a new jesse instance') .action((projectName, branch = 'master') => { commands_1.default.newProject(projectName, branch, commander_1.default.force); }); commander_1.default .command('upgrade') .description(`Upgrades an instance of jesse to latest code developed on the master branch. Leaves your ".env", db.sqlite, and custom strategies untouched.`) .action(() => { commands_1.default.upgradeProject(); }); commander_1.default .command('make:strategy') .description('Makes a new strategy folder in /strategies') .action(strategyName => { commands_1.default.makeStrategy(strategyName, commander_1.default.force); }); commander_1.default.command('*').action(command => { let matcher = new did_you_mean_1.default(); matcher.setThreshold(4); if (command.includes('make')) { matcher.add('make:strategy', 'init', 'upgrade'); } let matches = matcher.list(command); if (matches.length) { console.error(`Did you mean one of these?`); console.error(''); matches.forEach(match => { console.error(match.value); }); console.error(''); return; } }); commander_1.default.parse(process.argv); if (!process.argv.slice(2).length) { commander_1.default.outputHelp(); } //# sourceMappingURL=jesse.js.map