diff --git a/package.json b/package.json index 120f0eb6..3f560e5a 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@types/sinon": "9.0.11", "@types/sinon-chai": "3.2.5", "@types/source-map-support": "0.5.3", - "@types/yargs": "15.0.13", + "@types/yargs": "16.0.1", "@typescript-eslint/eslint-plugin": "4.19.0", "@typescript-eslint/eslint-plugin-tslint": "4.19.0", "@typescript-eslint/parser": "4.19.0", @@ -96,7 +96,7 @@ "tslint-microsoft-contrib": "6.2.0", "tslint-sonarts": "1.9.0", "typescript": "4.1.3", - "yargs": "15.4.1" + "yargs": "16.2.0" }, "dependencies": {}, "nyc": { diff --git a/src/app.ts b/src/app.ts index efbd60e9..82fa99d4 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,5 +1,4 @@ import { createLogger } from 'bunyan'; -import { showCompletionScript } from 'yargs'; import { loadConfig } from './config'; import { CONFIG_ARGS_NAME, CONFIG_ARGS_PATH, MODE, parseArgs } from './config/args'; @@ -10,6 +9,9 @@ import { readSource, writeSource } from './source'; import { VERSION_INFO } from './version'; import { VisitorContext } from './visitor/VisitorContext'; +/* eslint-disable-next-line @typescript-eslint/no-var-requires */ +const yargs = require('yargs'); + const ARGS_START = 2; export const STATUS_SUCCESS = 0; export const STATUS_ERROR = 1; @@ -18,7 +20,7 @@ export const STATUS_MAX = 255; export async function main(argv: Array): Promise { const { args, mode } = await parseArgs(argv.slice(ARGS_START)); if (mode === MODE.complete) { - showCompletionScript(); + yargs.showCompletionScript(); return STATUS_SUCCESS; } diff --git a/src/config/args.ts b/src/config/args.ts index 093b472c..21e67ae2 100644 --- a/src/config/args.ts +++ b/src/config/args.ts @@ -1,8 +1,9 @@ -import { Options, usage } from 'yargs'; - import { RuleSelector, RuleSources } from '../rule'; import { VERSION_INFO } from '../version'; +/* eslint-disable-next-line @typescript-eslint/no-var-requires */ +const yargs = require('yargs'); + export enum MODE { check = 'check', complete = 'complete', @@ -15,7 +16,7 @@ export enum MODE { export const CONFIG_ARGS_NAME = 'config-name'; export const CONFIG_ARGS_PATH = 'config-path'; -const RULE_OPTION: Options = { +const RULE_OPTION = { default: [], group: 'Rules:', type: 'array', @@ -49,7 +50,7 @@ export interface ParseResults { export async function parseArgs(argv: Array): Promise { let mode: MODE = MODE.check; - const parser = usage('Usage: salty-dog [options]') + const parser = yargs.usage('Usage: salty-dog [options]') .command({ command: ['check', '*'], describe: 'validate the source documents', @@ -58,7 +59,7 @@ export async function parseArgs(argv: Array): Promise { }, }) .command({ - builder: (yargs: any) => yargs.options({ + builder: (cmd: any) => cmd.options({ coerce: { default: false, type: 'boolean', diff --git a/yarn.lock b/yarn.lock index e43ac49a..36c40cfe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -449,10 +449,10 @@ resolved "https://artifacts.apextoaster.com/repository/group-npm/@types/yargs-parser/-/yargs-parser-13.1.0.tgz#c563aa192f39350a1d18da36c5a8da382bbd8228" integrity sha512-gCubfBUZ6KxzoibJ+SCUc/57Ms1jz5NjHe4+dI2krNmU5zCPAphyLJYyTOg06ueIyfj+SaCUqmzun7ImlxDcKg== -"@types/yargs@15.0.13": - version "15.0.13" - resolved "https://artifacts.apextoaster.com/repository/group-npm/@types/yargs/-/yargs-15.0.13.tgz#34f7fec8b389d7f3c1fd08026a5763e072d3c6dc" - integrity sha512-kQ5JNTrbDv3Rp5X2n/iUu37IJBDU2gsZ5R/g1/KHOOEc5IKfUFjXT6DENPGduh08I/pamwtEq4oul7gUqKTQDQ== +"@types/yargs@16.0.1": + version "16.0.1" + resolved "https://artifacts.apextoaster.com/repository/group-npm/@types/yargs/-/yargs-16.0.1.tgz#5fc5d41f69762e00fbecbc8d4bf9dea47d8726f4" + integrity sha512-x4HABGLyzr5hKUzBC9dvjciOTm11WVH1NWonNjGgxapnTHu5SWUqyqn0zQ6Re0yQU0lsQ6ztLCoMAKDGZflyxA== dependencies: "@types/yargs-parser" "*" @@ -625,11 +625,10 @@ ansi-styles@^3.2.0, ansi-styles@^3.2.1: color-convert "^1.9.0" ansi-styles@^4.0.0: - version "4.2.0" - resolved "https://artifacts.apextoaster.com/repository/group-npm/ansi-styles/-/ansi-styles-4.2.0.tgz#5681f0dcf7ae5880a7841d8831c4724ed9cc0172" - integrity sha512-7kFQgnEaMdRtwf6uSfUnVr9gSGC7faurn+J/Mv90/W+iTtN0405/nLdopfMWwchyxhbGYl6TC4Sccn9TUkGAgg== + version "4.3.0" + resolved "https://artifacts.apextoaster.com/repository/group-npm/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== dependencies: - "@types/color-name" "^1.1.1" color-convert "^2.0.1" ansi-styles@^4.1.0: @@ -4002,19 +4001,10 @@ string-width@^3.0.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" -string-width@^4.1.0: - version "4.1.0" - resolved "https://artifacts.apextoaster.com/repository/group-npm/string-width/-/string-width-4.1.0.tgz#ba846d1daa97c3c596155308063e075ed1c99aff" - integrity sha512-NrX+1dVVh+6Y9dnQ19pR0pP4FiEIlUvdTGn8pw6CKTNq5sgib2nIhmUNT5TAmhWmvKr3WcxBcP3E8nWezuipuQ== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^5.2.0" - -string-width@^4.2.0: - version "4.2.0" - resolved "https://artifacts.apextoaster.com/repository/group-npm/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" - integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== +string-width@^4.1.0, string-width@^4.2.0: + version "4.2.2" + resolved "https://artifacts.apextoaster.com/repository/group-npm/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5" + integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA== dependencies: emoji-regex "^8.0.0" is-fullwidth-code-point "^3.0.0" @@ -4565,7 +4555,7 @@ yargs-parser@^16.1.0: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^18.1.2, yargs-parser@^18.1.3: +yargs-parser@^18.1.3: version "18.1.3" resolved "https://artifacts.apextoaster.com/repository/group-npm/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ== @@ -4588,23 +4578,6 @@ yargs-unparser@2.0.0: flat "^5.0.2" is-plain-obj "^2.1.0" -yargs@15.4.1: - version "15.4.1" - resolved "https://artifacts.apextoaster.com/repository/group-npm/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8" - integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A== - dependencies: - cliui "^6.0.0" - decamelize "^1.2.0" - find-up "^4.1.0" - get-caller-file "^2.0.1" - require-directory "^2.1.1" - require-main-filename "^2.0.0" - set-blocking "^2.0.0" - string-width "^4.2.0" - which-module "^2.0.0" - y18n "^4.0.0" - yargs-parser "^18.1.2" - yargs@16.2.0, yargs@^16.0.0: version "16.2.0" resolved "https://artifacts.apextoaster.com/repository/group-npm/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66"