From 373a28ecc8fb75c8d50faa40b1c3a890e22da49a Mon Sep 17 00:00:00 2001 From: Anton SHEPILOV Date: Mon, 7 Apr 2025 22:44:46 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9Added=20configuration=20from=20env?= =?UTF-8?q?=20variables=20for=20cli=20Fixed=20cli=20tolls=20lib=20for=20no?= =?UTF-8?q?de=2022?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/custom-environment-variables.json | 161 ++++++++++++++++++ tdrive/backend/node/package-lock.json | 34 +--- tdrive/backend/node/package.json | 4 +- .../node/src/cli/cmds/dev_cmds/zip_folder.ts | 4 +- tdrive/backend/node/yarn.lock | 24 +-- 5 files changed, 178 insertions(+), 49 deletions(-) create mode 100644 tdrive/backend/node/bin/config/custom-environment-variables.json diff --git a/tdrive/backend/node/bin/config/custom-environment-variables.json b/tdrive/backend/node/bin/config/custom-environment-variables.json new file mode 100644 index 00000000..b14e85f3 --- /dev/null +++ b/tdrive/backend/node/bin/config/custom-environment-variables.json @@ -0,0 +1,161 @@ +{ + "general": { + "accounts": { + "type": "ACCOUNTS_TYPE", + "remote": { + "authority": "SSO_AUTHORITY", + "client_id": "SSO_CLIENT_ID", + "issuer": "SSO_ISSUER", + "jwks_uri": "SSO_JWKS_URI" + } + } + }, + "sentry": { + "dsn": "SENTRY_DSN" + }, + "logger": { + "level": "LOG_LEVEL" + }, + "admin": { + "endpointSecret": "ADMIN_ENDPOINT_SECRET" + }, + "diagnostics": { + "skipKeys": { + "__name": "DIAG_SKIP_KEYS", + "__format": "json" + }, + "probeSecret": "DIAG_PROBE_SECRET", + "statsLogPeriodMs": "DIAG_STATS_PRINT_PERIOD_MS", + "statsFullStatsLogPeriodMs": "DIAG_FULL_STATS_PRINT_PERIOD_MS" + }, + "webserver": { + "host": "TWAKE_DRIVE_HOST", + "logger": { + "level": "LOG_LEVEL" + }, + "static": { + "root": "STATIC_ROOT" + } + }, + "tracker": { + "segment": { + "key": "SEGMENT_SECRET_KEY" + } + }, + "auth": { + "jwt": { + "secret": "AUTH_JWT_SECRET" + } + }, + "database": { + "secret": "DB_SECRET", + "type": "DB_DRIVER", + "encryption": "DB_ENCRYPTION_ALGORITHM", + "mongodb": { + "uri": "DB_MONGO_URI", + "database": "DB_MONGO_DATABASE" + }, + "postgres": { + "database": "DB_POSTGRES_DBNAME", + "host": "DB_POSTGRES_HOST", + "user": "DB_POSTGRES_USERNAME", + "password": "DB_POSTGRES_PASSWORD", + "port": "DB_POSTGRES_PORT", + "ssl": "DB_POSTGRES_USE_SSL" + } + }, + "search": { + "type": "SEARCH_DRIVER", + "elasticsearch": { + "endpoint": "SEARCH_ES_ENDPOINT", + "flushInterval": "SEARCH_ES_FLUSHINTERVAL", + "useAuth": "SEARCH_ES_USE_AUTH", + "username": "SEARCH_ES_USERNAME", + "password": "SEARCH_ES_PASSWORD" + }, + "opensearch": { + "endpoint": "SEARCH_OS_ENDPOINT", + "flushInterval": "SEARCH_OS_FLUSHINTERVAL", + "useAuth": "SEARCH_OS_USE_AUTH", + "username": "SEARCH_OS_USERNAME", + "password": "SEARCH_OS_PASSWORD" + } + }, + "storage": { + "strategy": "STORAGE_STRATEGY", + "secret": "STORAGE_SECRET", + "iv": "STORAGE_SECRET_BASE_IV", + "type": "STORAGE_DRIVER", + "local": { + "path": "STORAGE_LOCAL_PATH" + }, + "oneof": { + "__name": "STORAGE_ONEOF", + "__format": "json" + }, + "S3": { + "homeDirectory": "STORAGE_S3_HOME_DIRECTORY", + "bucket": "STORAGE_S3_BUCKET", + "region": "STORAGE_S3_REGION", + "endPoint": "STORAGE_S3_ENDPOINT", + "port": "STORAGE_S3_PORT", + "useSSL": "STORAGE_S3_USE_SSL", + "accessKey": "STORAGE_S3_ACCESS_KEY", + "secretKey": "STORAGE_S3_SECRET_KEY", + "disableRemove": "STORAGE_S3_DISABLE_REMOVE", + "overrideDisableRemoveForUserAccountDeletion": "STORAGE_S3_OVERRIDE_DISABLE_REMOVE_FOR_USER_ACCOUNT_DELETION" + } + }, + "email-pusher": { + "email_interface": "EMAIL_INTERFACE", + "endpoint": "EMAIL_ENDPOINT", + "api_key": "EMAIL_API_KEY", + "sender": "EMAIL_SENDER", + "smtp_user": "EMAIL_SMTP_USER", + "smtp_password": "EMAIL_SMTP_PASSWORD", + "smtp_host": "EMAIL_SMTP_HOST", + "smtp_port": "EMAIL_SMTP_PORT", + "smtp_tls": "EMAIL_SMTP_SECURE", + "debug": "EMAIL_DEBUG", + "platform_url": "PLATFORM_URL" + }, + "message-queue": { + "type": "PUBSUB_TYPE", + "amqp": { + "urls": "PUBSUB_URLS" + } + }, + "applications": { + "__name": "APPLICATIONS", + "__format": "json", + "//": "//{\"grid\": [], \"plugins\": []}" + }, + "pusbub": { + "//": "//deprecated", + "type": "PUBSUB_TYPE", + "amqp": { + "urls": "PUBSUB_URLS" + } + }, + "plugins": { + "server": "PLUGINS_SERVER" + }, + "drive": { + "featureSharedDrive": "ENABLE_FEATURE_SHARED_DRIVE", + "rootAdmins": "DRIVE_ROOT_ADMINS", + "defaultLanguage": "DRIVE_DEFAULT_LANGUAGE", + "defaultCompany": "DRIVE_DEFAULT_COMPANY", + "defaultUserQuota": "DRIVE_DEFAULT_USER_QUOTA", + "featureDisplayEmail": "ENABLE_FEATURE_DISPLAY_EMAIL", + "featureUserQuota": "ENABLE_FEATURE_USER_QUOTA", + "featureManageAccess": "ENABLE_FEATURE_MANAGE_ACCESS", + "featureAntivirus": "ENABLE_FEATURE_ANTIVIRUS" + }, + "av": { + "host": "AV_HOST", + "port": "AV_PORT", + "debugMode": "AV_DEBUG_MODE", + "timeout": "AV_TIMEOUT", + "maxFileSize": "AV_MAX_FILE_SIZE" + } +} diff --git a/tdrive/backend/node/package-lock.json b/tdrive/backend/node/package-lock.json index 8baff1ad..f7ab06f0 100644 --- a/tdrive/backend/node/package-lock.json +++ b/tdrive/backend/node/package-lock.json @@ -36,7 +36,6 @@ "bcrypt": "^5.0.1", "clamscan": "^2.4.0", "class-transformer": "^0.3.1", - "cli-interact": "^0.1.9", "cli-table": "^0.3.6", "config": "^3.3.2", "deep-object-diff": "^1.1.0", @@ -76,6 +75,7 @@ "probe-image-size": "^7.2.3", "pump": "^3.0.0", "random-useragent": "^0.5.0", + "readline-sync": "^1.4.10", "redis": "3", "reflect-metadata": "^0.1.13", "rxjs": "^6.6.3", @@ -97,7 +97,6 @@ "@types/analytics-node": "^3.1.5", "@types/archiver": "^6.0.3", "@types/bcrypt": "^5.0.0", - "@types/cli-interact": "^0.1.4", "@types/cli-table": "^0.3.0", "@types/config": "0.0.36", "@types/eslint": "^7.2.3", @@ -115,6 +114,7 @@ "@types/pino": "^7.0.5", "@types/pump": "^1.1.1", "@types/random-useragent": "^0.3.1", + "@types/readline-sync": "^1.4.8", "@types/socket.io-client": "^1.4.36", "@types/unzipper": "^0.10.9", "@types/uuid": "^8.3.0", @@ -2639,15 +2639,6 @@ "@types/responselike": "^1.0.0" } }, - "node_modules/@types/cli-interact": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/@types/cli-interact/-/cli-interact-0.1.4.tgz", - "integrity": "sha512-ApnXGFz+j6Yb6v6UvD3c9eEMQG+4YARy/+ZkwQIMBW+HTuwtAw6QknlE2rdkVHuPdt+dn4WsArQjS1K/LT6L/w==", - "dev": true, - "dependencies": { - "@types/readline-sync": "*" - } - }, "node_modules/@types/cli-table": { "version": "0.3.4", "resolved": "https://registry.npmjs.org/@types/cli-table/-/cli-table-0.3.4.tgz", @@ -2958,7 +2949,8 @@ "version": "1.4.8", "resolved": "https://registry.npmjs.org/@types/readline-sync/-/readline-sync-1.4.8.tgz", "integrity": "sha512-BL7xOf0yKLA6baAX6MMOnYkoflUyj/c7y3pqMRfU0va7XlwHAOTOIo4x55P/qLfMsuaYdJJKubToLqRVmRtRZA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/responselike": { "version": "1.0.3", @@ -4577,17 +4569,6 @@ "node": ">=8" } }, - "node_modules/cli-interact": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/cli-interact/-/cli-interact-0.1.9.tgz", - "integrity": "sha512-QHrR2djQOfT1WfHSj9DidBGp+ImgV3t9dTP4cPWTnt9fnOcZqBzCoqd2RysWSIgUXuer5WpmKuT1jqjvwoxdCQ==", - "dependencies": { - "readline-sync": "~0.4.9" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/cli-spinners": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", @@ -10986,9 +10967,10 @@ } }, "node_modules/readline-sync": { - "version": "0.4.10", - "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-0.4.10.tgz", - "integrity": "sha512-q/RyXCZ+49a7octyBMENisHi11JVcnNORLDKEdKEzUnBBiszElOtdCY+wJKPCnwHuh/8+yfDoptGL7D79yUOLw==", + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz", + "integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==", + "license": "MIT", "engines": { "node": ">= 0.8.0" } diff --git a/tdrive/backend/node/package.json b/tdrive/backend/node/package.json index 5d312714..b91c9cdb 100644 --- a/tdrive/backend/node/package.json +++ b/tdrive/backend/node/package.json @@ -63,7 +63,6 @@ "@types/analytics-node": "^3.1.5", "@types/archiver": "^6.0.3", "@types/bcrypt": "^5.0.0", - "@types/cli-interact": "^0.1.4", "@types/cli-table": "^0.3.0", "@types/config": "0.0.36", "@types/eslint": "^7.2.3", @@ -81,6 +80,7 @@ "@types/pino": "^7.0.5", "@types/pump": "^1.1.1", "@types/random-useragent": "^0.3.1", + "@types/readline-sync": "^1.4.8", "@types/socket.io-client": "^1.4.36", "@types/unzipper": "^0.10.9", "@types/uuid": "^8.3.0", @@ -134,7 +134,6 @@ "bcrypt": "^5.0.1", "clamscan": "^2.4.0", "class-transformer": "^0.3.1", - "cli-interact": "^0.1.9", "cli-table": "^0.3.6", "config": "^3.3.2", "deep-object-diff": "^1.1.0", @@ -174,6 +173,7 @@ "probe-image-size": "^7.2.3", "pump": "^3.0.0", "random-useragent": "^0.5.0", + "readline-sync": "^1.4.10", "redis": "3", "reflect-metadata": "^0.1.13", "rxjs": "^6.6.3", diff --git a/tdrive/backend/node/src/cli/cmds/dev_cmds/zip_folder.ts b/tdrive/backend/node/src/cli/cmds/dev_cmds/zip_folder.ts index a59c99db..7dbc388b 100644 --- a/tdrive/backend/node/src/cli/cmds/dev_cmds/zip_folder.ts +++ b/tdrive/backend/node/src/cli/cmds/dev_cmds/zip_folder.ts @@ -9,7 +9,7 @@ import globalResolver from "../../../services/global-resolver"; import fs from "fs"; import { CompanyExecutionContext, DriveItemDetails } from "../../../services/documents/types"; import { randomUUID } from "crypto"; -import { getYesNo } from "cli-interact"; +import { keyInYN } from "readline-sync"; type ZipCommandArgs = { verbose: boolean; @@ -52,7 +52,7 @@ export default { await zipFolder(toZip, tmpFilePath, context); _spinner.info(`Folder successfully zipped to "${tmpFilePath}"`); //create a new document with this file in users root directory - if (getYesNo("Do you want to upload file?")) { + if (keyInYN("Do you want to upload file?")) { await saveFile(tmpFilePath, `${toZip.item.name}.zip`, context); _spinner.info(`"${toZip.item.name}.zip" saved to users home directory`); fs.rmSync(tmpFilePath); diff --git a/tdrive/backend/node/yarn.lock b/tdrive/backend/node/yarn.lock index 00d29616..20d1560e 100644 --- a/tdrive/backend/node/yarn.lock +++ b/tdrive/backend/node/yarn.lock @@ -1170,13 +1170,6 @@ "@types/node" "*" "@types/responselike" "^1.0.0" -"@types/cli-interact@^0.1.4": - version "0.1.4" - resolved "https://registry.npmjs.org/@types/cli-interact/-/cli-interact-0.1.4.tgz" - integrity sha512-ApnXGFz+j6Yb6v6UvD3c9eEMQG+4YARy/+ZkwQIMBW+HTuwtAw6QknlE2rdkVHuPdt+dn4WsArQjS1K/LT6L/w== - dependencies: - "@types/readline-sync" "*" - "@types/cli-table@^0.3.0": version "0.3.4" resolved "https://registry.npmjs.org/@types/cli-table/-/cli-table-0.3.4.tgz" @@ -1447,7 +1440,7 @@ dependencies: "@types/node" "*" -"@types/readline-sync@*": +"@types/readline-sync@^1.4.8": version "1.4.8" resolved "https://registry.npmjs.org/@types/readline-sync/-/readline-sync-1.4.8.tgz" integrity sha512-BL7xOf0yKLA6baAX6MMOnYkoflUyj/c7y3pqMRfU0va7XlwHAOTOIo4x55P/qLfMsuaYdJJKubToLqRVmRtRZA== @@ -2392,13 +2385,6 @@ cli-cursor@^3.1.0: dependencies: restore-cursor "^3.1.0" -cli-interact@^0.1.9: - version "0.1.9" - resolved "https://registry.npmjs.org/cli-interact/-/cli-interact-0.1.9.tgz" - integrity sha512-QHrR2djQOfT1WfHSj9DidBGp+ImgV3t9dTP4cPWTnt9fnOcZqBzCoqd2RysWSIgUXuer5WpmKuT1jqjvwoxdCQ== - dependencies: - readline-sync "~0.4.9" - cli-spinners@^2.5.0: version "2.9.2" resolved "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz" @@ -6267,10 +6253,10 @@ readdirp@~3.6.0: dependencies: picomatch "^2.2.1" -readline-sync@~0.4.9: - version "0.4.10" - resolved "https://registry.npmjs.org/readline-sync/-/readline-sync-0.4.10.tgz" - integrity sha512-q/RyXCZ+49a7octyBMENisHi11JVcnNORLDKEdKEzUnBBiszElOtdCY+wJKPCnwHuh/8+yfDoptGL7D79yUOLw== +readline-sync@^1.4.10: + version "1.4.10" + resolved "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz" + integrity sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw== real-require@^0.2.0: version "0.2.0"