Chaining publish and unpublish Commands Changes Their Default Behavior
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 1.2k
- フォーク
- 271
- 平均マージ
- 23時間 40分
- マージ済み PR(30日)
- 2
説明
Describe the bug
Chaining publish and unpublish commands changes their default behavior in relation to staging/production hosts.
Expected Behavior
Commands publish and unpublish should always default to staging when production_host and staging_host are defined under binary in package.json.
Actual Behavior
When the commands publish and unpublish are executed by themselves they default to staging. However, if the command being executed is chained after another command (for example package publish or info unpublish) then the default reverts to binary.production_host. As a result - accidental publishing/unpublishing is possible.
Steps to Reproduce
1) Prep package.json
Replace "host" with staging_host and production_host in package.json
Example:
"staging_host": "https://apm-appoptics-bindings-node-dev-staging.s3.us-east-1.amazonaws.com",
"production_host": "https://apm-appoptics-bindings-node-dev-production.s3.us-east-1.amazonaws.com",
2) Run Commands one after the other
node-pre-gyp package
node-pre-gyp publish
Results in: ✅
[node-pre-gyp-test-app1] published to https://apm-appoptics-bindings-node-dev-staging.s3.us-east-1.amazonaws.com/node-pre-gyp/node-pre-gyp-test-app1/v0.1.0/Release/
node-pre-gyp info
node-pre-gyp unpublish
Results in: ✅
[node-pre-gyp-test-app1] Success: removed https://apm-appoptics-bindings-node-dev-staging.s3.amazonaws.com/node-pre-gyp/node-pre-gyp-test-app1/v0.1.0/Release/node-v83-darwin-x64.tar.gz
3) Run Chained Commands
node-pre-gyp package publish
Results in: ❌
[node-pre-gyp-test-app1] published to https://apm-appoptics-bindings-node-dev-production.s3.us-east-1.amazonaws.com/node-pre-gyp/node-pre-gyp-test-app1/v0.1.0/Release/
node-pre-gyp info unpublish
Results in: ❌
[node-pre-gyp-test-app1] Success: removed https://apm-appoptics-bindings-node-dev-production.s3.amazonaws.com/node-pre-gyp/node-pre-gyp-test-app1/v0.1.0/Release/node-v83-darwin-x64.tar.gz
Root Cause
When chained commands are executed, the first command in the chain will raise the binaryHostSet flag. Subsequent publish or unpublish will trigger the early return. Due to the early return, the host will not be configured correctly resulting in the bug described above.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
lib/node-pre-gyp.js の247行目と275行目付近にある binaryHostSet の処理から始め、示されている package.json の staging_host と production_host の値で問題を再現します。単独の publish/unpublish コマンドと連結した publish/unpublish コマンドの両方で修正を検証します。連結したコマンドは、production ではなく staging をデフォルトで使用する必要があります。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- cli
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 48/100