From fda8127b4efbb024bc1d10d05df8899c2db00585 Mon Sep 17 00:00:00 2001
From: Tom French <tom@tomfren.ch>
Date: Mon, 16 May 2022 15:30:42 +0100
Subject: [PATCH] docs: add documentation on how to build the protobuf

---
 packages/loot-core/src/server/sync/README.md  | 20 +++++++++++++++----
 .../src/server/sync/proto/sync_pb.js          |  3 +++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/packages/loot-core/src/server/sync/README.md b/packages/loot-core/src/server/sync/README.md
index 0077e83d1..5df92100c 100644
--- a/packages/loot-core/src/server/sync/README.md
+++ b/packages/loot-core/src/server/sync/README.md
@@ -1,17 +1,29 @@
+# protobuf
+
+We use [protobuf](https://developers.google.com/protocol-buffers/) to encode messages as binary data to send across the network.
+
 ## Generating protobuf
 
-We use protobuf to encode messages as binary data to send across the network.
+The protobuf is generated by using the [protoc](https://github.com/protocolbuffers/protobuf) compiler.
+
+This can be installed by downloading one of the [pre-built binaries](https://github.com/protocolbuffers/protobuf/releases/) and placing it in your `$PATH`. The version used to build the current protobuf is [v3.20.1](https://github.com/protocolbuffers/protobuf/releases/tag/v3.20.1).
+
+Once installed, the protobuf can be generated by running the below commands.
 
-To generate the protobuf: I forget, will document this soon.
+```bash
+cd packages/loot-core/src/server/sync
+
+protoc sync.proto --js_out=import_style=commonjs,binary:proto
+```
 
 However there is one very important thing to remember! The default output includes this near the top:
 
 ```
-var global = Function('return this')();
+var global = (function() { return this || window || global || self || Function('return this')(); }).call(null);
 ```
 
 This will not work with our CSP directives. You must manually modify this to this:
 
 ```
 var global = globalThis;
-```
\ No newline at end of file
+```
diff --git a/packages/loot-core/src/server/sync/proto/sync_pb.js b/packages/loot-core/src/server/sync/proto/sync_pb.js
index f8100d436..65bdc528b 100644
--- a/packages/loot-core/src/server/sync/proto/sync_pb.js
+++ b/packages/loot-core/src/server/sync/proto/sync_pb.js
@@ -2,11 +2,14 @@
 /**
  * @fileoverview
  * @enhanceable
+ * @suppress {missingRequire} reports error on implicit type usages.
  * @suppress {messageConventions} JS Compiler reports an error if a variable or
  *     field starts with 'MSG_' and isn't a translatable message.
  * @public
  */
 // GENERATED CODE -- DO NOT EDIT!
+/* eslint-disable */
+// @ts-nocheck
 
 var jspb = require('google-protobuf');
 var goog = jspb;
-- 
GitLab