Chaining publish and unpublish Commands Changes Their Default Behavior
還沒有人認領這個 Issue。
- 主要語言
- JavaScript
- 星號
- 1.2k
- 分支
- 271
- 平均合併
- 23 小時 40 分鐘
- 30 天內合併 PR
- 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 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 lib/node-pre-gyp.js 中第247行和第275行附近的 binaryHostSet 處理開始,然後使用所示的 package.json staging_host 和 production_host 值重現該問題。使用獨立的和鏈式的 publish/unpublish 命令驗證修正;鏈式命令應預設使用 staging,而不是 production。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- javascript
- 領域
- cli
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 48/100