xhiroga / aws-peacock-management-console

Browser Extension to show account alias and change color of AWS Management Console, even if AWS SSO.
MIT License
85 stars 10 forks source link

yaml configuration support #23

Closed sogaoh closed 2 years ago

sogaoh commented 2 years ago

Description

v1.3 時点ではオプションでの Configuration は json (+アルファ?) 形式での設定が想定されているように感じます。 設定を yaml で行えるようになっていると、コメントが書きやすい・フォーマット(lint)を気にする機会が減る、 と思うので可能であれば yaml 対応いただきたいです。

Use Case

Proposed Solution

Other information

No response

Acknowledge

umireon commented 2 years ago

YAMLパーサーはJSONもパースできるので、コンフィグのパースをJSON.parseからYAMLのライブラリに置き換えるだけでこれは実現できます

xhiroga commented 2 years ago

いいですね! JSONCもパースしてくれるかは確認したいところです。

もしくは変換はユーザーに任せ、URL経由でJSONを読み取るという手も…

umireon commented 2 years ago

JSONCのパースはYAMLのライブラリでは無理そうです。

#-で始まったらYAML、/[で始まったらJSONCとしてパースすればいいんじゃないでしょうか?

umireon commented 2 years ago
const configListIsYaml = (configList: string) => /^\s*[#-]/.test(configList)
const configListIsJsonc = (configList: string) => /^\s*[\/\[]/.test(configList)

configListIsYaml(configList) ? YAML.parse(configList) :
configListIsJsonc(configList) ? JSONC.parse(configList) :
JSON.parse(configList)
xhiroga commented 2 years ago

Now YAML supported!!!

image

(Account ID is dummy)

image