diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 71e10756949a73210a18ab2108e604371315803b..b7dc1bdfd44fa803a37bdf4f2eedcce9e8bf042a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,17 +2,15 @@ stages: - deploy publish_npm: - image: "node:19.3-alpine3.17" + image: "node:20.18-alpine3.19" stage: deploy variables: GIT_SUBMODULE_STRATEGY: recursive before_script: - 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 + - apk add --update make bash protobuf-dev + - cd ./config && npm i && cd ../ rules: - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' @@ -32,6 +30,6 @@ publish_npm: fi - NPM_PACKAGE_NAME=$(node -p "require('./package.json').name") - NPM_PACKAGE_CURRENT_VERSION=$(npm show ${NPM_PACKAGE_NAME} version) - - yarn pub + - npm pub - NPM_PACKAGE_VERSION=$(node -p "require('./package.json').version") - echo "Successfully published version ${NPM_PACKAGE_VERSION} of ${NPM_PACKAGE_NAME} to GitLab's NPM registry" \ No newline at end of file diff --git a/Makefile b/Makefile index 62cb983aed02f5cc56d35a68b7852d23a79c0bdf..47fc8cd3689ab624b4ae21dd89414ccdcc3b2b95 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,15 @@ SHELL = /bin/bash -o pipefail PROTODIR=perxis-proto/proto DSTDIR=config/dist +TSPROTOPLUGIN=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) $(shell mkdir $(DSTDIR)) # Генерация @@ -22,7 +20,7 @@ js-client: protoc-check js-check $(PROTOTSFILES) generate-js %.ts: %.proto @protoc -I=$(PROTODIR) \ - --plugin=@protoc-gen-ts_proto \ + --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) \ "$<" @@ -41,34 +39,17 @@ 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 +endif \ No newline at end of file diff --git a/config/generate.sh b/config/generate.sh index 636aae6cf1ed206830201e3dc0be7e463a7d78c5..3f6b1a7943b50432d956fc746b0a45a1e566aec4 100755 --- a/config/generate.sh +++ b/config/generate.sh @@ -47,21 +47,17 @@ generate_index() { done } +cd ./config echo "Generate index.ts files" -ts_files=$(find ./config/dist/**/ -name '*.ts') +ts_files=$(find ./dist -name '*.ts' -type f) 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 --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 '*.ts' ! -name '*.d.ts' -type f -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 2fa43997358f98abd15cda2dd72e8b3abca0330d..4cbbc47779a1a89e7e06e6455782457be4b386f1 100644 --- a/config/package.json +++ b/config/package.json @@ -1,11 +1,11 @@ { "name": "@perxis-js/perxis-client", - "version": "1.5.6", - "description": "", - "main": "dist/index.js", + "version": "1.5.8", + "description": "Perxis API клиент для JavaScript", "files": [ - "dist/" + "dist" ], + "main": "./dist/index.js", "repository": { "type": "git", "url": "git+https://git.perx.ru/perxis/perxis-js.git" @@ -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 e5b1de8fc933afc364abfc7ea5ab772b222bc1dd..05f7cb2cf6eca01942bec8fa37cc8c02c06ed45f 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": "ES2016" /* 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": "CommonJS" /* 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 deleted file mode 100644 index 33edd69a176c7e8fc63d2b22e43fc6bb0cd1c6ee..0000000000000000000000000000000000000000 --- a/config/yarn.lock +++ /dev/null @@ -1,84 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@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= - -"@protobufjs/base64@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" - integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== - -"@protobufjs/codegen@^2.0.4": - version "2.0.4" - resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" - integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== - -"@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= - -"@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= - dependencies: - "@protobufjs/aspromise" "^1.1.1" - "@protobufjs/inquire" "^1.1.0" - -"@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= - -"@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= - -"@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= - -"@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= - -"@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= - -"@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== - -long@^5.0.0: - 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== - dependencies: - "@protobufjs/aspromise" "^1.1.2" - "@protobufjs/base64" "^1.1.2" - "@protobufjs/codegen" "^2.0.4" - "@protobufjs/eventemitter" "^1.1.0" - "@protobufjs/fetch" "^1.1.0" - "@protobufjs/float" "^1.0.2" - "@protobufjs/inquire" "^1.1.0" - "@protobufjs/path" "^1.1.2" - "@protobufjs/pool" "^1.1.0" - "@protobufjs/utf8" "^1.1.0" - "@types/node" ">=13.7.0" - long "^5.0.0" diff --git a/perxis-proto b/perxis-proto index c45f4b158bbb7e119a665cbd5f70f72df2803d87..a5054e6e91b176ca421ebf659b32c751e07c81cc 160000 --- a/perxis-proto +++ b/perxis-proto @@ -1 +1 @@ -Subproject commit c45f4b158bbb7e119a665cbd5f70f72df2803d87 +Subproject commit a5054e6e91b176ca421ebf659b32c751e07c81cc