diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bfccb223b50981e5ec210d2b962c6486a6583a89..bba08208dff69459ef3752b167770c064c6dfd1e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,13 +10,13 @@ publish_npm: - apk add --update make bash protobuf-dev yarn - npm install -g ts-proto@1.115.5 - npm install -g typescript@4.7.4 + - npm i protobufjs@6.11.3 rules: - - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' changes: - config/package.json script: - - mkdir config/dist - make proto - cd ./config - | diff --git a/Makefile b/Makefile index c32db0ebca3a61ebe07af897665454fc8c220ebf..5ded41975ee2ba85c36077c97af9bf92c3fdab40 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ SHELL = /bin/bash -o pipefail PROTODIR=perxis-proto/proto DSTDIR=config/dist + ALLPROTO?=$(shell find $(PROTODIR) -name '*.proto' ) PROTOFILES= $(filter-out proto/status/status.proto, $(ALLPROTO)) PROTOTSFILES=$(ALLPROTO:.proto=.ts) @@ -13,6 +14,7 @@ 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)) # Генерация proto: protoc-check js-check $(PROTOTSFILES) generate-ts generate-js @@ -71,4 +73,4 @@ ifneq ($(shell expr $(TSC_MINOR_VERSION) \>= 7), 1) endif ifneq ($(shell expr $(TSC_MIC_VERSION) \>= 4), 1) $(error "Current version is lower than 4.7.4 Please update typescript \n") -endif \ No newline at end of file +endif diff --git a/config/generate.sh b/config/generate.sh index 3ce8f55e761c25f21804e99da37fc7e907c47d5d..636aae6cf1ed206830201e3dc0be7e463a7d78c5 100755 --- a/config/generate.sh +++ b/config/generate.sh @@ -23,26 +23,20 @@ generate_index() { if [ "$segment" == "$base" ]; then exp="export * from './$exac'" - if grep -Fxq "$exp" "$dir"/index.ts; then - echo "$exp" "-> current expression-string already exist in index.ts" - else + if ! grep -Fxq "$exp" "$dir"/index.ts; then echo "$exp" | tee -a "$dir"/index.ts fi p="" elif [ "$segment" == "$exac" ]; then exp="export * as $segment from './$segment'" - if grep -Fxq "$exp" "$p"/index.ts; then - echo "$exp" "-> current expression-string already exist in index.ts" - else - echo "$exp" | tee -a "$p"/index.ts + if ! grep -Fxq "$exp" "$p"/index.ts; then + echo "$exp" | tee -a "$p"/index.ts fi p+="$segment" p+="/" else exp="export * as $segment from './$segment'" - if grep -Fxq "$exp" "$p"index.ts; then - echo "$exp" "-> current expression-string already exist in index.ts" - else + if ! grep -Fxq "$exp" "$p"index.ts; then echo "$exp" | tee -a "$p"index.ts fi p+="$segment" @@ -53,29 +47,16 @@ generate_index() { done } -echo "---deleting existing *.d.ts, *.d.ts.map, *.js, *.js.map files" -find ./config/dist/*/**/ -path '*.d.ts' -delete -find ./config/dist/*/**/ -path '*.d.ts.map' -delete -find ./config/dist/*/**/ -path '*.js' -delete -find ./config/dist/*/**/ -path '*.js.map' -delete -find ./config/dist/*/**/ -path '*.ts.bak' -delete -find ./config/dist -path '*.d.ts' -delete -find ./config/dist -path '*.d.ts.map' -delete -find ./config/dist -path '*.js' -delete -find ./config/dist -path '*.js.map' -delete -find ./config/dist -path '*.ts.bak' -delete echo "Generate index.ts files" ts_files=$(find ./config/dist/**/ -name '*.ts') ts_files_array=($ts_files) generate_index "${ts_files_array[@]}" -echo "---generating *.d.ts, *.d.ts.map, *.js, *.js.map files" -npm i protobufjs@6.11.3 +echo "Generate *.d.ts, *.d.ts.map, *.js, *.js.map files" tsc --project ./config --declaration --declarationMap --sourceMap --rootDir ./config/dist -echo "---deleting created tmp files" -npm uninstall protobufjs@6.11.3 +echo "Delete created tmp files" find ./config/dist -name 'index.ts' -delete find ./config/dist/*/** -name 'index.ts' -delete find ./config/ -maxdepth 1 -name 'index.ts' -delete