@@ -21,8 +21,14 @@ const neatFrame = require('neat-frame')
2121const { stripIndent } = require ( 'common-tags' )
2222
2323// # Pure functions
24- function publicGatewayUrl ( hash ) {
25- return `https://ipfs.io/ipfs/${ hash } `
24+ function httpGatewayUrl ( hash , gatewayProvider = 'ipfs' ) {
25+ const gateways = {
26+ ipfs : 'https://ipfs.io' ,
27+ infura : 'https://ipfs.infura.io' ,
28+ pinata : 'https://gateway.pinata.cloud' ,
29+ }
30+ const origin = gateways [ gatewayProvider ] || gateways [ 'ipfs' ]
31+ return `${ origin } /ipfs/${ hash } `
2632}
2733
2834function formatError ( e ) {
@@ -300,17 +306,17 @@ async function addToInfura(publicDirPath) {
300306 }
301307}
302308
303- function copyUrlToClipboard ( hash ) {
309+ function copyUrlToClipboard ( url ) {
304310 const spinner = ora ( )
305- spinner . start ( '📋 Copying public gateway URL to clipboard…' )
306- clipboardy . writeSync ( publicGatewayUrl ( hash ) )
307- spinner . succeed ( '📋 Copied public gateway URL to clipboard:' )
308- spinner . info ( `🔗 ${ chalk . green ( publicGatewayUrl ( hash ) ) } ` )
311+ spinner . start ( '📋 Copying HTTP gateway URL to clipboard…' )
312+ clipboardy . writeSync ( url )
313+ spinner . succeed ( '📋 Copied HTTP gateway URL to clipboard:' )
314+ spinner . info ( `🔗 ${ chalk . green ( url ) } ` )
309315}
310316
311317async function deploy ( {
312318 publicDirPath,
313- copyPublicGatewayUrlToClipboard = false ,
319+ copyHttpGatewayUrlToClipboard = false ,
314320 open = false ,
315321 port = '4002' ,
316322 remotePinners = [ 'infura' ] ,
@@ -370,23 +376,24 @@ async function deploy({
370376
371377 if ( successfulRemotePinners . length > 0 ) {
372378 const pinnedHash = Object . values ( pinnedHashes ) [ 0 ]
379+ const gatewayUrl = httpGatewayUrl ( pinnedHash , successfulRemotePinners [ 0 ] )
373380 const isEqual = hash => hash === pinnedHash
374381 if ( ! fp . every ( isEqual ) ( Object . values ( pinnedHashes ) ) ) {
375382 const spinner = ora ( )
376383 spinner . fail ( '≠ Found inconsistency in pinned hashes:' )
377384 logError ( pinnedHashes )
378385 }
379386
380- if ( copyPublicGatewayUrlToClipboard ) {
381- copyUrlToClipboard ( pinnedHash )
387+ if ( copyHttpGatewayUrlToClipboard ) {
388+ copyUrlToClipboard ( gatewayUrl )
382389 }
383390
384391 if ( dnsProviders . includes ( 'cloudflare' ) ) {
385392 await updateCloudflareDns ( siteDomain , credentials . cloudflare , pinnedHash )
386393 }
387394
388395 if ( open && _ . isEmpty ( dnsProviders ) ) {
389- await openUrl ( publicGatewayUrl ( pinnedHash ) )
396+ await openUrl ( gatewayUrl )
390397 }
391398 if ( open && ! _ . isEmpty ( dnsProviders ) ) {
392399 await openUrl ( `https://${ siteDomain } ` )
0 commit comments