diff --git a/.editorconfig b/.editorconfig index db99a87..9371aa3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,4 +9,5 @@ charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space -indent_size = 2 \ No newline at end of file +indent_size = 2 +max_line_length = 160 diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 4bbceca..b3b8628 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -28,6 +28,9 @@ jobs: - name: Install dependencies run: npm ci + - name: Run linter + run: npm run lint + - name: Publish package to npm if: ${{ github.head_ref == 'master' }} env: diff --git a/package-lock.json b/package-lock.json index 13fa3bf..1317b8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6232,9 +6232,9 @@ "dev": true }, "exos-scripts": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/exos-scripts/-/exos-scripts-1.0.0.tgz", - "integrity": "sha512-TEiA2ZK6O2orNy1AACvTgWsmzID42z1fh4KjgAwSc3cLmqLT/cLXCQ5ou4VFvRGSawP4DuvDOyjf5mhTwScuVw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/exos-scripts/-/exos-scripts-1.0.1.tgz", + "integrity": "sha512-Pn3f11LaQQlrApUEzU6wcux4Y1MTbCXtdAQYe9Va55oj8NK1xayS/Sp+5ypD0paJqeHCAl0xQjG19MVJ/HlN/A==", "dev": true, "requires": { "@svgr/webpack": "^5.3.0", diff --git a/package.json b/package.json index 0c2c8ed..d8ff141 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@types/node": "^13.11.1", "@types/yargs-interactive": "^2.1.0", "chalk": "^4.0.0", - "exos-scripts": "^1.0.0", + "exos-scripts": "^1.0.1", "semantic-release": "^17.1.1", "typescript": "^3.9.5" } diff --git a/src/cli/get-command-options.ts b/src/cli/get-command-options.ts index f56819d..a9de227 100644 --- a/src/cli/get-command-options.ts +++ b/src/cli/get-command-options.ts @@ -1,20 +1,20 @@ -const defaultOptions = { +import type { Option } from "yargs-interactive"; + +const defaultOptions: Option = { interactive: { describe: "Use interactive mode", default: true }, }; -interface CommandOption { - default: unknown; -} - /** * Check current options and decide what to do. * If there is a missing property, run interactive mode * using the other properties as default values * @param commandOptions */ -function getCommandOptions(commandOptions: CommandOption[]): unknown { - const toReturn = Object.assign({}, defaultOptions, commandOptions); - return toReturn; +function getCommandOptions(commandOptions: Option): Option { + return { + ...defaultOptions, + ...commandOptions, + }; } export default getCommandOptions; diff --git a/src/cli/index.ts b/src/cli/index.ts index 4d58e46..02ce009 100755 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -4,7 +4,17 @@ import getCliVersion from "./get-cli-version"; import getCommandOptions from "./get-command-options"; import chalk from "chalk"; -const yargsConfig = yargsInteractive(); +// temporary fix until yargs.interactive is updated +import type { Argv } from "yargs"; +import type { Option } from "yargs-interactive"; + +interface Interactive extends Argv { + usage(usage: string): Interactive; + interactive(options: Option): Interactive; + then(callback: (result: unknown) => unknown): Interactive; +} + +const yargsConfig = yargsInteractive() as Interactive; /* * This CLI has two levels: @@ -24,12 +34,10 @@ availableCommands.forEach((command) => { // Run yargsInteractive again to obtain the command options. // Use interactive mode is a property is missing. // Execute the command handler at the end. - return yargsInteractive() - .interactive(commandOptions as any) - .then(commandHandler); + return yargsInteractive().interactive(commandOptions).then(commandHandler); }; - (yargsConfig as any).command(command); + yargsConfig.command(command); }); export default function cli(): unknown { @@ -41,10 +49,6 @@ export default function cli(): unknown { console.log(); // Run yargsInteractive for the first time to obtain the command to use - return (yargsConfig as any) - .usage("$0 [args]") - .demandCommand(1, 1, "You need to specify a command before moving on") - .help() - .wrap(null) - .version(cliVersion).argv; + return yargsConfig.usage("$0 [args]").demandCommand(1, 1, "You need to specify a command before moving on").help().wrap(null).version(cliVersion) + .argv; } diff --git a/src/exos-cli.ts b/src/exos-cli.ts index a304430..8cf39ed 100644 --- a/src/exos-cli.ts +++ b/src/exos-cli.ts @@ -1,4 +1,4 @@ -#! /usr/bin/env node +#!/usr/bin/env node import cli from "./cli"; // Run yargsInteractive for the first time to obtain the command to use.