-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: switch to GitHub downloads (#45)
Web3Storage doesn't have free usage any more so switch to downloading tarballs from GitHub release pages instead and verifying them against an expected CID.
- Loading branch information
1 parent
98b1f09
commit a241ea3
Showing
10 changed files
with
182 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-disable no-console */ | ||
import fs from 'node:fs' | ||
import { join, resolve } from 'node:path' | ||
import * as url from 'node:url' | ||
import { hashFile } from '../src/hash-file.js' | ||
import { ARCHITECTURES } from '../src/arches.js' | ||
|
||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) | ||
const versionsPath = join(__dirname, '..', 'src', 'versions.json') | ||
|
||
const version = fs.readFileSync(join(__dirname, '..', 'Makefile'), { | ||
encoding: 'utf8' | ||
}) | ||
.split('\n') | ||
.map(line => line.trim()) | ||
.filter(line => line.startsWith('COMMIT?=')) | ||
.pop() | ||
.replace('COMMIT?=', '') | ||
|
||
const versions = {} | ||
|
||
for (const arch of ARCHITECTURES) { | ||
const filePath = resolve(join(__dirname, '..', `p2pd-${version}-${arch}.${arch.includes('win32') ? 'zip' : 'tar.gz'}`)) | ||
const cid = await hashFile(filePath) | ||
versions[arch] = cid.toString() | ||
} | ||
|
||
const manifest = JSON.parse(fs.readFileSync(versionsPath, { | ||
encoding: 'utf8' | ||
})) | ||
|
||
manifest.versions[version] = versions | ||
|
||
fs.writeFileSync(versionsPath, JSON.stringify(manifest, null, 2), { | ||
encoding: 'utf8' | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const ARCHITECTURES = [ | ||
'darwin', | ||
'linux-386', | ||
'linux-amd64', | ||
'linux-arm64', | ||
'win32-386', | ||
'win32-amd64', | ||
'win32-arm64' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import fs from 'node:fs' | ||
import { BlackHoleBlockstore } from 'blockstore-core/black-hole' | ||
import { importer } from 'ipfs-unixfs-importer' | ||
import { fixedSize } from 'ipfs-unixfs-importer/chunker' | ||
import { balanced } from 'ipfs-unixfs-importer/layout' | ||
import last from 'it-last' | ||
|
||
/** | ||
* @typedef {import('multiformats/cid').CID} CID | ||
*/ | ||
|
||
/** | ||
* @param {string} filePath | ||
* @returns {Promise<CID>} | ||
*/ | ||
export async function hashFile (filePath) { | ||
const blockstore = new BlackHoleBlockstore() | ||
const input = fs.createReadStream(filePath) | ||
const result = await last(importer([{ | ||
content: input | ||
}], blockstore, { | ||
cidVersion: 1, | ||
rawLeaves: true, | ||
chunker: fixedSize({ chunkSize: 1024 * 1024 }), | ||
layout: balanced({ maxChildrenPerNode: 1024 }) | ||
})) | ||
|
||
if (result == null) { | ||
throw new Error('Import failed') | ||
} | ||
|
||
return result.cid | ||
} |
Oops, something went wrong.