Browse Source

chore(deps): remove the lnrpc proto file workaround

feat/auto-update
jamaljsr 5 years ago
parent
commit
afd584163a
  1. 3
      package.json
  2. 35
      tools/lnrpcProto.js

3
package.json

@ -21,12 +21,11 @@
"lint": "eslint --ext .ts,.tsx --ignore-path .gitignore .",
"lint:all": "yarn tsc && yarn lint",
"lint:fix": "yarn lint --fix",
"package": "yarn proto && yarn build && yarn package:electron",
"package": "yarn build && yarn package:electron",
"package:ci": "yarn package --publish onTagOrDraft",
"package:electron": "electron-builder build -c.extraMetadata.main=build/main/electron/index.js --config .electronbuildrc",
"postinstall": "electron-builder install-app-deps",
"prebuild": "tsc -p electron/tsconfig.json",
"proto": "node ./tools/lnrpcProto.js",
"release": "standard-version --no-verify",
"start": "rescripts start",
"test": "cross-env DEBUG_PRINT_LIMIT=15000 rescripts test",

35
tools/lnrpcProto.js

@ -1,35 +0,0 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const lnrpcPkgJson = require('@radar/lnrpc/package.json');
const { join } = require('path');
const { outputFile, pathExists, readFile } = require('fs-extra');
/**
* The lnrpc library copies the rpc.proto file on first use. Since the packaged
* app on Mac stores the node_modules in app.asar, it cannot write the file at
* runtime. This function does the copy manually and should be run before
* packaging the app with electron-builder
* see: https://github.com/RadarTech/lnrpc/blob/c45de55019fb112500ff586361738c3cf18f51e9/lib/lnrpc.js#L125
*/
const copyProto = async () => {
console.log('Copying lnrpc rpc.proto file');
const lnrpcPath = join('node_modules', '@radar', 'lnrpc');
const protoSrc = join(
lnrpcPath,
`lnd/${lnrpcPkgJson.config['lnd-release-tag']}/rpc.proto`,
);
const protoDest = join(lnrpcPath, 'rpc.proto');
console.log(` - src: ${protoSrc}`);
console.log(` - dest: ${protoDest}`);
if (!(await pathExists(protoDest))) {
let grpcSrc = await readFile(protoSrc, 'utf8');
// remove google annotations causing parse error on `grpc.load()`
grpcSrc = grpcSrc.replace('import "google/api/annotations.proto";', '');
await outputFile(protoDest, grpcSrc);
console.log(' -> copied!');
} else {
console.log(' -> file already exists');
}
};
copyProto();
Loading…
Cancel
Save