From 91feca8d8c5261c7c2ef89a9c84eb6d3b3d89d26 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 27 Dec 2024 12:20:34 -0500 Subject: [PATCH] adjust proto hash --- .../Services/Innertube/protos/params.proto.gen.bs | 2 +- tools/bs-plugins/proto-gen-plugin.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/playlet-lib/src/components/Services/Innertube/protos/params.proto.gen.bs b/playlet-lib/src/components/Services/Innertube/protos/params.proto.gen.bs index 5a0bc4ac..c68f7266 100644 --- a/playlet-lib/src/components/Services/Innertube/protos/params.proto.gen.bs +++ b/playlet-lib/src/components/Services/Innertube/protos/params.proto.gen.bs @@ -1,5 +1,5 @@ ' Auto-generated file - do not modify manually -' md5:ab48a52d517ca819a9720973f690d0e5 +' md5:a67e7e5809b87399b499043edf609988 import "pkg:/source/Protobuf/BinaryReader.bs" import "pkg:/source/Protobuf/BinaryWriter.bs" diff --git a/tools/bs-plugins/proto-gen-plugin.ts b/tools/bs-plugins/proto-gen-plugin.ts index e13b5a33..686bcf7b 100644 --- a/tools/bs-plugins/proto-gen-plugin.ts +++ b/tools/bs-plugins/proto-gen-plugin.ts @@ -14,6 +14,8 @@ const protobufSchema = require('protocol-buffers-schema') export class ProtoGenPlugin implements CompilerPlugin { public name = 'ProtoGenPlugin'; + private currentFileHash: string | undefined; + afterProgramCreate(program: Program) { // @ts-ignore program.options.forceGenerateProtos = true; @@ -38,7 +40,7 @@ export class ProtoGenPlugin implements CompilerPlugin { program.logger.info(`Generating proto from ${protoFile}`); const protoContent = readFileSync(protoFile, 'binary'); - const protoHash = md5(protoContent).toString(); + const protoHash = md5(protoContent + this.getCurrentFileHash()).toString(); if (!forceGenerateProtos && existsSync(outputFile)) { const firstLine = readFileSync(outputFile, 'utf8').split('\n')[1]; @@ -248,6 +250,16 @@ end function`; return new Formatter(options); } + + getCurrentFileHash() { + // hash current file (this plugin) - if it changes, it invalidates all generated files + if (this.currentFileHash) { + return this.currentFileHash; + } + const pluginContent = readFileSync(__filename, 'binary'); + this.currentFileHash = md5(pluginContent).toString(); + return this.currentFileHash; + } } export default () => {