Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

fix: switch to generated protobuf code for grpc-protocol #3655

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ipfs-client/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
/** @type {import('aegir').PartialOptions} */
module.exports = {
build: {
bundlesizeMax: '120kB'
bundlesizeMax: '122kB'
}
}
8 changes: 3 additions & 5 deletions packages/ipfs-grpc-client/src/utils/load-services.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

// @ts-ignore
const protocol = require('ipfs-grpc-protocol')
const protobuf = require('protobufjs/light')
const { Service } = protobuf
Expand All @@ -19,17 +18,16 @@ const CONVERSION_OPTS = {
* service definition on both the server and the client.
*/
module.exports = function loadServices () {
const root = protobuf.Root.fromJSON(protocol)
/** @type {Record<string, any>} */
const output = {}

Object
// @ts-ignore
.keys(root.nested.ipfs)
.keys(protocol.ipfs)
// @ts-ignore
.filter(key => root.nested.ipfs[key] instanceof Service)
.filter(key => protocol.ipfs[key] instanceof Service)
// @ts-ignore
.map(key => root.nested.ipfs[key])
.map(key => protocol.ipfs[key])
.forEach(service => {
/** @type {Record<string, any>} */
const serviceDef = {}
Expand Down
8 changes: 6 additions & 2 deletions packages/ipfs-grpc-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"keywords": [
"ipfs"
],
"main": "dist/ipfs.json",
"main": "src/index.js",
"types": "src/index.d.ts",
"homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-protocol#readme",
"bugs": "https://github.com/ipfs/js-ipfs/issues",
"license": "(Apache-2.0 OR MIT)",
Expand All @@ -22,10 +23,13 @@
"test": "echo 'No tests here'",
"clean": "rimraf ./dist",
"prepare": "npm run build",
"build": "npm run clean && mkdirp ./dist && pbjs ./src/*.proto -t json -o ./dist/ipfs.json"
"build": "run-s clean build:*",
"build:proto": "pbjs -t static-module -w commonjs -r ipfs-grpc-protocol --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/index.js ./src/*.proto",
"build:proto-types": "pbts -o src/index.d.ts src/index.js"
},
"devDependencies": {
"mkdirp": "^1.0.4",
"npm-run-all": "^4.1.5",
"protobufjs": "^6.10.2",
"rimraf": "^3.0.2"
}
Expand Down
Loading