From 877a16f44452b02f5f65c9cae403b5b0a8cba2bc Mon Sep 17 00:00:00 2001
From: Dmitry Karyakin <skycrazyk@gmail.com>
Date: Tue, 22 Oct 2024 12:40:53 +0200
Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?=
 =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?=
 =?UTF-8?q?=D0=B5=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D1=85?=
 =?UTF-8?q?=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitlab-ci.yml     |  3 +--
 Makefile           | 31 +++----------------------------
 config/generate.sh |  6 +++---
 3 files changed, 7 insertions(+), 33 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 956ee48..b7dc1bd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -13,8 +13,7 @@ publish_npm:
     - cd ./config && npm i && cd ../
 
   rules:
-    # - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
-    - if: '$CI_COMMIT_BRANCH'
+    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
       changes:
         - config/package.json
   script:
diff --git a/Makefile b/Makefile
index 905b5fd..47fc8cd 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ SHELL = /bin/bash -o pipefail
 
 PROTODIR=perxis-proto/proto
 DSTDIR=config/dist
-TSPROTODIR=config/node_modules/.bin/protoc-gen-ts_proto
+TSPROTOPLUGIN=config/node_modules/.bin/protoc-gen-ts_proto
 
 
 ALLPROTO?=$(shell find $(PROTODIR) -name '*.proto' )
@@ -12,9 +12,6 @@ PROTOTSFILES=$(ALLPROTO:.proto=.ts)
 
 # PROTOC_MAJOR_VERSION=$(shell protoc --version | awk '{print $$2;}' | cut -d. -f1)
 # PROTOC_MINOR_VERSION=$(shell protoc --version | awk '{print $$2;}' | cut -d. -f2)
-# TSC_MAJOR_VERSION=$(shell tsc --version | awk '{print $$2;}' | cut -d. -f1)
-# TSC_MINOR_VERSION=$(shell tsc --version | awk '{print $$2;}' | cut -d. -f2)
-# TSC_MIC_VERSION=$(shell tsc --version | awk '{print $$2;}' | cut -d. -f3)
 $(shell mkdir $(DSTDIR))
 
 # Генерация
@@ -23,7 +20,7 @@ js-client: protoc-check js-check $(PROTOTSFILES) generate-js
 
 %.ts: %.proto
 	@protoc -I=$(PROTODIR) \
-	--plugin=$(TSPROTODIR) \
+	--plugin=$(TSPROTOPLUGIN) \
  	--ts_proto_opt=env=browser,outputServices=generic-definitions,outputJsonMethods=false,esModuleInterop=true,useOptionals=messages,exportCommonSymbols=false,useDate=false,useExactTypes=false \
  	--ts_proto_out=$(DSTDIR) \
  	"$<"
@@ -55,26 +52,4 @@ js-check:
 ifeq (,$(shell which npm))
 	$(error "NPM not found. Run for linux: \"sudo apt install npm\", for mac: \"brew install npm\" \
 	or visit \"https://docs.npmjs.com/getting-started\" for more.\n")
-endif
-# TODO точная версия ставится локально через npm i поэтому проверка не требуется
-# ifeq (,$(shell which protoc-gen-ts_proto))
-# 	$(error "Ts-proto plugin for protoc not found. \
-# 	Run \"npm install -g ts-proto@1.158.0\" \
-# 	or visit \"https://github.com/stephenh/ts-proto\" for more.\n")
-# endif
-# ifeq (,$(shell which tsc))
-# 	$(error "Typescript not found. \
-# 	Run \"npm install -g typescript@5.6.3\" \
-# 	or visit \"https://github.com/microsoft/TypeScript\" for more.\n")
-# endif
-# BUG проверка для минимальной версии 5.1.6 будет ошибочно не пройдена с версией 5.6.3 так как
-# каждая цифра проверяется отдельно
-# ifneq ($(shell expr $(TSC_MAJOR_VERSION) \>= 5), 1)
-#   	 $(error "Current version is outdated. Please update typescript \n")
-# endif
-# ifneq ($(shell expr $(TSC_MINOR_VERSION) \>= 1), 1)
-#   	 $(error "Current version is lower than 5.1 Please update typescript \n")
-# endif
-# ifneq ($(shell expr $(TSC_MIC_VERSION) \>= 6), 1)
-#   	 $(error "Current version is lower than 5.1.6 Please update typescript \n")
-# endif
+endif
\ No newline at end of file
diff --git a/config/generate.sh b/config/generate.sh
index d9721fb..3f6b1a7 100755
--- a/config/generate.sh
+++ b/config/generate.sh
@@ -50,14 +50,14 @@ generate_index() {
 cd ./config
 
 echo "Generate index.ts files"
-ts_files=$(find ./dist/**/ -name '*.ts')
+ts_files=$(find ./dist -name '*.ts' -type f)
 ts_files_array=($ts_files)
 generate_index "${ts_files_array[@]}"
 
 echo "Generate *.js files"
-npx tsc --project ./ --declaration --declarationMap --sourceMap --rootDir ./dist
+npx tsc --declaration --declarationMap --sourceMap --rootDir ./dist
 
 echo "Delete temporary files"
-find ./dist -name 'index.ts' -type f -delete
+find ./dist -name '*.ts' ! -name '*.d.ts' -type f -delete
 
 echo "Process finished"
\ No newline at end of file
-- 
GitLab