@@ -2,6 +2,7 @@ const IPFSFactory = require('ipfsd-ctl')
22const which = require ( 'which' )
33const clipboardy = require ( 'clipboardy' )
44const pinataSDK = require ( '@pinata/sdk' )
5+ const got = require ( 'got' )
56const updateCloudflareDnslink = require ( 'dnslink-cloudflare' )
67const ora = require ( 'ora' )
78
@@ -49,14 +50,14 @@ async function main() {
4950
5051 const spinner = ora ( )
5152 spinner . start ( )
52- spinner . info ( 'βοΈConnecting to local IPFS daemon...' )
53+ spinner . info ( 'βοΈ Connecting to local IPFS daemon...' )
5354
5455 df . spawn ( { disposable : false , init : false , start : false } , ( err , ipfsd ) => {
5556 if ( err ) throw err
5657
5758 ipfsd . start ( [ ] , ( err2 , ipfsClient ) => {
5859 if ( err2 ) throw err2
59- spinner . succeed ( 'πΆ Connected.' )
60+ spinner . succeed ( 'πΆ Connected.' )
6061
6162 spinner . info ( 'πΎ Adding and pinning ./public/ locally...' )
6263 ipfsClient . addFromFs (
@@ -66,7 +67,7 @@ async function main() {
6667 if ( err3 ) throw err3
6768
6869 const { hash } = localPinResult [ localPinResult . length - 1 ]
69- spinner . succeed ( `#οΈβ£ Added locally as ${ hash } .` )
70+ spinner . succeed ( `π Added locally as ${ hash } .` )
7071
7172 ipfsClient . id ( ( err4 , { addresses } ) => {
7273 if ( err4 ) throw err4
@@ -93,12 +94,28 @@ async function main() {
9394 process . env . PINATA_SECRET_API_KEY
9495 )
9596
96- spinner . info ( 'π Requesting remote pin to Pinata .cloud...' )
97+ spinner . info ( 'π Requesting remote pin to pinata .cloud...' )
9798 pinata
9899 . pinHashToIPFS ( hash , pinataOptions )
99- . then ( _pinataPinResult => {
100+ . then ( async _pinataPinResult => {
100101 spinner . succeed ( "π It's pinned to Pinata now." )
101102
103+ try {
104+ spinner . info ( 'π Requesting remote pin to infura.io...' )
105+ const infuraResponse = await got (
106+ `https://ipfs.infura.io:5001/api/v0/pin/add?arg=${ hash } ` +
107+ '&recursive=true'
108+ )
109+
110+ if ( infuraResponse . statusCode === 200 ) {
111+ spinner . succeed ( "π It's pinned to Infura now." )
112+ } else {
113+ spinner . fail ( "Pinning to Infura didn't work." )
114+ }
115+ } catch ( e ) {
116+ console . error ( e )
117+ }
118+
102119 clipboardy . writeSync ( hash )
103120 spinner . succeed ( `π Hash ${ hash } copied to clipboard.` )
104121
0 commit comments