Eliminating getters from yargs Options

オープン
#272 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
typescript
領域
cli

調査の方向性

Start with the getters for openReport, dryRun, interactive, verbose, and rcPath, and review the earlier changes in pull request #270. Trace how each option is read and identify the code changes needed to preserve behavior when removing the getters. Done means all five getters are removed without behavior changes; the issue does not name specific tests to run.

索引モデルが issue の本文から書いたものです。

説明

TL;DR

Some Parameter have a get function which will cause issues when migrating to ESM and require using incorrect typing.

These need to be removed.

Description

Using the getter for a parameter is requiring use to use Type Assertions.

This is an issue because it will not work property in some cases and typescript will ignore the error.

As an example we can look at the verbose param:

// packages/cli/src/lib/global/options/verbose.ts

import { argv } from 'yargs';
import { Param } from './verbose.model';
import { ArgvOption } from '../../core/yargs/types';
import { GlobalOptionsArgv } from './types';
import { getEnvPreset } from '../../pre-set';


export const param: Param = {
  verbose: {
    alias: 'v',
    type: 'boolean',
    description: 'Run with verbose logging',
    default: getEnvPreset().verbose
  }
};

// We don't rely on yargs option normalization features as this can happen before cli bootstrap
export function get(): boolean  {
  const {verbose} = argv as unknown as GlobalOptionsArgv;
  return verbose;
}

Going around the yargs parser is problematic as it means we cannot simply expect it to work in the same way it yargs is suppose to.

Many of the getters for the options are being removed in this MR: https://github.com/push-based/user-flow/pull/270

However some require making further modifications to the code base to not have any behaviour changes.

In particular I am referring to the the following yargs options:

  • openReport
  • dryRun
  • interactive
  • verbose
  • rcPath
Issue with getters in ESM

I believe the issue is related to live bindings. Or more broadly the way ES6 Modules export works.

More resources on the topic:

What do ES6 modules export? by Axel Rauschmayer
ES modules: A cartoon deep-dive by Lin Clark
Chapter on Modules in Exploring JS by Axel Rauschmayer

主要言語
HTML
スター
131
フォーク
7
平均マージ
1日 1時間
マージ済み PR(30日)
10

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

push-based/user-flow のほかの issue

push-based/user-flow の issue をすべて見る

似ている issue

CLI の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。