UNPKG

typescript-assistant

Version:

Combines and integrates professional Typescript tools into your project

82 lines 3.61 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fix_1 = require("./commands/fix"); const clean_1 = require("./commands/clean"); const release_1 = require("./commands/release"); const assist_1 = require("./commands/assist"); const post_checkout_1 = require("./commands/post-checkout"); const post_merge_1 = require("./commands/post-merge"); const pre_commit_1 = require("./commands/pre-commit"); const ci_1 = require("./commands/ci"); const yargsModule = require("yargs"); const dependency_injector_1 = require("./dependency-injector"); const pre_push_1 = require("./commands/pre-push"); const fix_all_1 = require("./commands/fix-all"); const init_1 = require("./commands/init"); const lint_1 = require("./commands/lint"); const semver_1 = require("semver"); /* tslint:disable:no-console */ if (semver_1.gte('v7.0.0', process.version)) { console.error('Please update your version of Node.'); process.exit(1); } let inject = dependency_injector_1.createDependencyInjector(); /* tslint:disable:no-console */ let onSuccess = () => { process.exit(0); }; let onFailure = (error) => { console.error(error); process.exit(1); }; let failIfUnsuccessful = (success) => { if (!success) { process.exit(1); } }; yargsModule.command(['assist', '*'], 'Watches for file changes and outputs current errors and violations', {}, (yargs) => { if (yargs._.length === 0 || yargs._.length === 1 && yargs._[0] === 'assist') { inject(assist_1.createAssistCommand).execute(); } else { console.error('Unknown command'); process.exit(1); } }); yargsModule.command(['lint'], 'Lints', {}, yargs => { inject(lint_1.createLintCommand).execute().then(onSuccess, onFailure); }); yargsModule.command(['fix', 'f'], 'Formats changed files and applies tslint fixes', {}, (yargs) => { inject(fix_1.createFixCommand).execute().then(onSuccess, onFailure); }); yargsModule.command(['fixall'], 'Formats all files and applies tslint fixes', {}, (yargs) => { inject(fix_all_1.createFixAllCommand).execute().then(onSuccess, onFailure); }); yargsModule.command(['clean', 'c'], 'Deletes all output files and intermediate files', {}, (yargs) => { inject(clean_1.createCleanCommand).execute(); }); yargsModule.command(['release'], 'Interactively makes a new version number, tags, pushes and publishes to npm', {}, (yargs) => { inject(release_1.createReleaseCommand).execute().then(onSuccess, onFailure); }); yargsModule.command(['ci'], 'Runs all tools in parallel to find errors', {}, (yargs) => { inject(ci_1.createCICommand).execute().then(failIfUnsuccessful, onFailure); }); yargsModule.command('init', 'Initialize or repair all features of typescript-assistant in your project', {}, (yargs) => { inject(init_1.createInitCommand).execute(true); }); yargsModule.command('pre-commit', 'Pre-commit git hook for husky', {}, (yargs) => { inject(pre_commit_1.createPreCommitCommand).execute().then(onSuccess, onFailure); }); yargsModule.command('post-checkout', 'Post-checkout git hook for husky', {}, (yargs) => { inject(post_checkout_1.createPostCheckoutCommand).execute(); }); yargsModule.command('post-merge', 'Post-merge git hook for husky', {}, (yargs) => { inject(post_merge_1.createPostMergeCommand).execute(); }); yargsModule.command('pre-push', 'Pre-push git hook for husky', {}, (yargs) => { inject(pre_push_1.createPrePushCommand).execute().then(failIfUnsuccessful, onFailure); }); yargsModule.strict().argv; /* tslint:enable:no-console */ //# sourceMappingURL=index.js.map