From 55a97a2af37088dd7f40a5d6973df231b46513a3 Mon Sep 17 00:00:00 2001 From: Dmitry Karyakin <skycrazyk@gmail.com> Date: Mon, 21 Oct 2024 16:48:07 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F=20ts-proto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 10 +++--- Makefile | 68 +++++++++++++++++++---------------- config/generate.sh | 23 ++++++------ config/package.json | 12 ++++--- config/tsconfig.json | 10 +++--- config/yarn.lock | 86 +++++++++++++++++++++++++++++++++++--------- perxis-proto | 2 +- 7 files changed, 137 insertions(+), 74 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 71e1075..cf41fff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ stages: - deploy publish_npm: - image: "node:19.3-alpine3.17" + image: "node:20.18-alpine3.19" stage: deploy variables: GIT_SUBMODULE_STRATEGY: recursive @@ -10,12 +10,12 @@ publish_npm: - apk --no-cache add git - git submodule update --remote --merge - apk add --update make bash protobuf-dev yarn - - npm install -g ts-proto@1.158.0 - - npm install -g typescript@5.1.6 - - npm i protobufjs@7.2.4 + - cd ./config + - npm i rules: - - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + # - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + - if: '$CI_COMMIT_BRANCH' changes: - config/package.json script: diff --git a/Makefile b/Makefile index 62cb983..905b5fd 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,18 @@ SHELL = /bin/bash -o pipefail PROTODIR=perxis-proto/proto DSTDIR=config/dist +TSPROTODIR=config/node_modules/.bin/protoc-gen-ts_proto ALLPROTO?=$(shell find $(PROTODIR) -name '*.proto' ) PROTOFILES= $(filter-out proto/status/status.proto, $(ALLPROTO)) 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) +# 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)) # Генерация @@ -22,7 +23,7 @@ js-client: protoc-check js-check $(PROTOTSFILES) generate-js %.ts: %.proto @protoc -I=$(PROTODIR) \ - --plugin=@protoc-gen-ts_proto \ + --plugin=$(TSPROTODIR) \ --ts_proto_opt=env=browser,outputServices=generic-definitions,outputJsonMethods=false,esModuleInterop=true,useOptionals=messages,exportCommonSymbols=false,useDate=false,useExactTypes=false \ --ts_proto_out=$(DSTDIR) \ "$<" @@ -41,34 +42,39 @@ ifeq (,$(shell which protoc)) $(error "Protocol Buffers not found. Run for linux: \"sudo apt install -y protobuf-compiler\", for mac: \"brew install protobuf\" \ or visit \"https://grpc.io/docs/protoc-installation/\" for more.\n") endif -ifneq ($(shell expr $(PROTOC_MAJOR_VERSION) \>= 3),1) - $(error "Current version is outdated. Please update protoc") -endif -ifneq ($(shell expr $(PROTOC_MINOR_VERSION) \>= 21), 1) - $(error "Current version is lower than 3.21. Please update protoc") -endif +# BUG проверка для минимальной версии 3.21 будет ошибочно не пройдена с версией 3.30 так как +# каждая цифра проверяется отдельно +# ifneq ($(shell expr $(PROTOC_MAJOR_VERSION) \>= 3),1) +# $(error "Current version is outdated. Please update protoc") +# endif +# ifneq ($(shell expr $(PROTOC_MINOR_VERSION) \>= 21), 1) +# $(error "Current version is lower than 3.21. Please update protoc") +# endif 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 -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.1.6\" \ - or visit \"https://github.com/microsoft/TypeScript\" for more.\n") -endif -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 +# 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 diff --git a/config/generate.sh b/config/generate.sh index 636aae6..9e71b03 100755 --- a/config/generate.sh +++ b/config/generate.sh @@ -47,21 +47,22 @@ generate_index() { done } +cd ./config echo "Generate index.ts files" -ts_files=$(find ./config/dist/**/ -name '*.ts') +ts_files=$(find ./dist/**/ -name '*.ts') ts_files_array=($ts_files) generate_index "${ts_files_array[@]}" -echo "Generate *.d.ts, *.d.ts.map, *.js, *.js.map files" -tsc --project ./config --declaration --declarationMap --sourceMap --rootDir ./config/dist +echo "Generate *.js files" +npx tsc --project ./ --declaration --declarationMap --sourceMap --rootDir ./dist -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 -find ./ -maxdepth 1 -name '*.json' -delete -find ./ -maxdepth 1 -name '*.ts' -delete -find ./config/dist/*/** -name '*.ts' ! -name '*.d.ts' -delete +echo "Delete temporary files" +find ./dist -name 'index.ts' -delete +find ./dist/*/** -name 'index.ts' -delete +find ./dist -maxdepth 1 -name 'index.ts' -delete +find ./dist -maxdepth 1 -name '*.json' -delete +find ./dist -maxdepth 1 -name '*.ts' -delete +find ./dist/*/** -name '*.ts' ! -name '*.d.ts' -delete -echo "---process finished" \ No newline at end of file +echo "Process finished" \ No newline at end of file diff --git a/config/package.json b/config/package.json index 2fa4399..9ab07e4 100644 --- a/config/package.json +++ b/config/package.json @@ -1,6 +1,6 @@ { "name": "@perxis-js/perxis-client", - "version": "1.5.6", + "version": "1.5.7", "description": "", "main": "dist/index.js", "files": [ @@ -13,9 +13,11 @@ "scripts": { "pub": "npm publish" }, - "dependencies": { - "protobufjs": "7.2.4" - }, "author": "", - "license": "ISC" + "license": "ISC", + "dependencies": { + "protobufjs": "7.4.0", + "ts-proto": "1.181.2", + "typescript": "5.6.3" + } } diff --git a/config/tsconfig.json b/config/tsconfig.json index e5b1de8..79ebf40 100644 --- a/config/tsconfig.json +++ b/config/tsconfig.json @@ -11,7 +11,7 @@ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ /* Language and Environment */ - "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ // "jsx": "preserve", /* Specify what JSX code is generated. */ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ @@ -24,7 +24,7 @@ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ /* Modules */ - "module": "CommonJS" /* Specify what module code is generated. */, + "module": "NodeNext" /* Specify what module code is generated. */, // "rootDir": "./", /* Specify the root folder within your source files. */ // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ @@ -69,9 +69,9 @@ /* Interop Constraints */ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */, + "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */, // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, + // "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, /* Type Checking */ "strict": true /* Enable all strict type-checking options. */, @@ -96,7 +96,7 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ }, "include": [ "./dist/**/*" diff --git a/config/yarn.lock b/config/yarn.lock index 33edd69..a376dbc 100644 --- a/config/yarn.lock +++ b/config/yarn.lock @@ -5,7 +5,7 @@ "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" - integrity sha1-m4sMxmPWaafY9vXQiToU00jzD78= + integrity sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ== "@protobufjs/base64@^1.1.2": version "1.1.2" @@ -20,12 +20,12 @@ "@protobufjs/eventemitter@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" - integrity sha1-NVy8mLr61ZePntCV85diHx0Ga3A= + integrity sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q== "@protobufjs/fetch@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" - integrity sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU= + integrity sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ== dependencies: "@protobufjs/aspromise" "^1.1.1" "@protobufjs/inquire" "^1.1.0" @@ -33,42 +33,61 @@ "@protobufjs/float@^1.0.2": version "1.0.2" resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" - integrity sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E= + integrity sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ== "@protobufjs/inquire@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" - integrity sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik= + integrity sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q== "@protobufjs/path@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" - integrity sha1-bMKyDFya1q0NzP0hynZz2Nf79o0= + integrity sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA== "@protobufjs/pool@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" - integrity sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q= + integrity sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw== "@protobufjs/utf8@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" - integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= + integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== "@types/node@>=13.7.0": - version "16.11.12" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.12.tgz#ac7fb693ac587ee182c3780c26eb65546a1a3c10" - integrity sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw== + version "22.7.7" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.7.tgz#6cd9541c3dccb4f7e8b141b491443f4a1570e307" + integrity sha512-SRxCrrg9CL/y54aiMCG3edPKdprgMVGDXjA3gB8UmmBW5TcXzRUYAh8EWzTnSJFAd1rgImPELza+A3bJ+qxz8Q== + dependencies: + undici-types "~6.19.2" + +case-anything@^2.1.13: + version "2.1.13" + resolved "https://registry.yarnpkg.com/case-anything/-/case-anything-2.1.13.tgz#0cdc16278cb29a7fcdeb072400da3f342ba329e9" + integrity sha512-zlOQ80VrQ2Ue+ymH5OuM/DlDq64mEm+B9UTdHULv5osUMD6HalNTblf2b1u/m6QecjsnOkBpqVZ+XPwIVsy7Ng== -long@^5.0.0: +detect-libc@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + integrity sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg== + +dprint-node@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/dprint-node/-/dprint-node-1.0.8.tgz#a02470722d8208a7d7eb3704328afda1d6758625" + integrity sha512-iVKnUtYfGrYcW1ZAlfR/F59cUVL8QIhWoBJoSjkkdua/dkWIgjZfiLMeTjiB06X0ZLkQ0M2C1VbUj/CxkIf1zg== + dependencies: + detect-libc "^1.0.3" + +long@^5.0.0, long@^5.2.3: version "5.2.3" resolved "https://registry.yarnpkg.com/long/-/long-5.2.3.tgz#a3ba97f3877cf1d778eccbcb048525ebb77499e1" integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q== -protobufjs@7.2.4: - version "7.2.4" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.2.4.tgz#3fc1ec0cdc89dd91aef9ba6037ba07408485c3ae" - integrity sha512-AT+RJgD2sH8phPmCf7OUZR8xGdcJRga4+1cOaXJ64hvcSkVhNcRHOwIxUatPH15+nj59WAGTDv3LSGZPEQbJaQ== +protobufjs@7.4.0, protobufjs@^7.2.4: + version "7.4.0" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.4.0.tgz#7efe324ce9b3b61c82aae5de810d287bc08a248a" + integrity sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw== dependencies: "@protobufjs/aspromise" "^1.1.2" "@protobufjs/base64" "^1.1.2" @@ -82,3 +101,38 @@ protobufjs@7.2.4: "@protobufjs/utf8" "^1.1.0" "@types/node" ">=13.7.0" long "^5.0.0" + +ts-poet@^6.7.0: + version "6.9.0" + resolved "https://registry.yarnpkg.com/ts-poet/-/ts-poet-6.9.0.tgz#e63ac8d8a9e91a2e0e5d2bf0755db71346728bd2" + integrity sha512-roe6W6MeZmCjRmppyfOURklO5tQFQ6Sg7swURKkwYJvV7dbGCrK28um5+51iW3twdPRKtwarqFAVMU6G1mvnuQ== + dependencies: + dprint-node "^1.0.8" + +ts-proto-descriptors@1.16.0: + version "1.16.0" + resolved "https://registry.yarnpkg.com/ts-proto-descriptors/-/ts-proto-descriptors-1.16.0.tgz#e9f15d5d23774088f8573fa5a2d75130c64a565a" + integrity sha512-3yKuzMLpltdpcyQji1PJZRfoo4OJjNieKTYkQY8pF7xGKsYz/RHe3aEe4KiRxcinoBmnEhmuI+yJTxLb922ULA== + dependencies: + long "^5.2.3" + protobufjs "^7.2.4" + +ts-proto@1.181.2: + version "1.181.2" + resolved "https://registry.yarnpkg.com/ts-proto/-/ts-proto-1.181.2.tgz#62696b4d84666bd6e237afc7090ba19e865ebfd0" + integrity sha512-knJ8dtjn2Pd0c5ZGZG8z9DMiD4PUY8iGI9T9tb8DvGdWRMkLpf0WcPO7G+7cmbZyxvNTAG6ci3fybEaFgMZIvg== + dependencies: + case-anything "^2.1.13" + protobufjs "^7.2.4" + ts-poet "^6.7.0" + ts-proto-descriptors "1.16.0" + +typescript@5.6.3: + version "5.6.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.3.tgz#5f3449e31c9d94febb17de03cc081dd56d81db5b" + integrity sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw== + +undici-types@~6.19.2: + version "6.19.8" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" + integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== diff --git a/perxis-proto b/perxis-proto index c45f4b1..a5054e6 160000 --- a/perxis-proto +++ b/perxis-proto @@ -1 +1 @@ -Subproject commit c45f4b158bbb7e119a665cbd5f70f72df2803d87 +Subproject commit a5054e6e91b176ca421ebf659b32c751e07c81cc -- GitLab