mapbox / mapbox/node-pre-gyp

Chaining publish and unpublish Commands Changes Their Default Behavior

Aperta
#653 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
JavaScript
Stelle
1.2k
Fork
271
Merge medio
23h 40m
PR unite (30g)
2

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in lib/node-pre-gyp.js, nella gestione di binaryHostSet intorno alle righe 247 e 275, quindi riproduci il problema con i valori staging_host e production_host di package.json mostrati. Verifica la correzione sia con comandi publish/unpublish autonomi sia concatenati; i comandi concatenati devono usare staging per impostazione predefinita invece di production.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
cli
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.