git ssb

3+

cel / ssb-npm-registry



Commit 49058f5f9a406656f03018486b4535f0bcb5250b

Make bootstrap snippet idempotent and more robust

cel committed on 8/30/2018, 3:21:35 AM
Parent: 8c002450411e07771334a9760bce28ba16957a1e

Files changed

index.jschanged
index.jsView
@@ -581,8 +581,9 @@
581581 var self = this
582582 var pkgs = self.server.npmConfig.defaultPkgs || ['scuttlebot', 'ssb-npm', 'git-ssb']
583583 var ssbNpmRegistryName = require('./package.json').name
584584 var ssbNpmRegistryVersion = require('./package.json').version
585 + var ssbNpmRegistryNameVersion = ssbNpmRegistryName + '-' + ssbNpmRegistryVersion
585586 var ssbNpmRegistrySpec = ssbNpmRegistryName + '@^' + ssbNpmRegistryVersion
586587 var done = multicb({pluck: 1, spread: true})
587588 self.resolvePkg(ssbNpmRegistrySpec, done())
588589 self.resolvePkgs(pkgs, done())
@@ -595,18 +596,17 @@
595596 var globalPkgs = pkgsInfo.map(function (info) {
596597 return info.name + '@' + info.version
597598 }).join(' ')
598599 var npmCmd = 'install -g ' + globalPkgs
599- var pkgTmpText = '/tmp/' + ssbNpmRegistryName + '.tar.gz'
600 + var tmpDir = '/tmp/' + encodeURIComponent(ssbNpmRegistryNameVersion)
600601 var tarballLink = self.wsLink + '/blobs/get/' + ssbNpmRegistryBlobId
601602
602603 var script =
603- 'wget \'' + tarballLink + '\' -O ' + pkgTmpText + ' &&\n' +
604- 'echo \'' + ssbNpmRegistryBlobHex + ' ' + pkgTmpText + '\' | sha256sum -c &&\n' +
605- 'mkdir -p ~/.ssb/node_modules && cd ~/.ssb/node_modules &&\n' +
606- 'tar xzf ' + pkgTmpText + ' &&\n' +
607- 'mv package ' + ssbNpmRegistryName + ' &&\n' +
608- ssbNpmRegistryName + '/bootstrap/bin.js --ws-url ' + self.wsLink + ' \\\n' +
604 + 'mkdir -p ' + tmpDir + ' && cd ' + tmpDir + ' &&\n' +
605 + 'wget -q \'' + tarballLink + '\' -O package.tgz &&\n' +
606 + 'echo \'' + ssbNpmRegistryBlobHex + ' package.tgz\' | sha256sum -c &&\n' +
607 + 'tar xzf package.tgz &&\n' +
608 + './*/bootstrap/bin.js --ws-url ' + self.wsLink + ' \\\n' +
609609 pkgMsgs.map(function (id) {
610610 return ' --branch ' + id + ' \\\n'
611611 }).join('') +
612612 ' -- ' + npmCmd + ' &&\n' +

Built with git-ssb-web