chore: run lint and prettifier

This commit is contained in:
3252a8
2026-05-12 21:54:12 +03:00
parent f31540afdb
commit 11187487b4
174 changed files with 12383 additions and 6688 deletions
+16 -20
View File
@@ -8,14 +8,7 @@ import { transform } from "esbuild";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const repoRoot = path.resolve(__dirname, "..");
const sourcePath = path.join(
repoRoot,
"bot",
"app",
"web",
"templates",
"subscription_webapp.js",
);
const sourcePath = path.join(repoRoot, "bot", "app", "web", "templates", "subscription_webapp.js");
function normalizeLineEndings(value) {
return value.replace(/\r\n/g, "\n");
@@ -35,16 +28,17 @@ function stripMarkedBlock(source, startMarker, endMarker) {
function stripFallbackI18n(source) {
const fallbackStart = source.indexOf(" const FALLBACK_I18N = {");
const i18nLine = " const I18N = readJsonScript('i18n') || (MOCK && MOCK.i18n) || FALLBACK_I18N;";
const i18nLine =
" const I18N = readJsonScript('i18n') || (MOCK && MOCK.i18n) || FALLBACK_I18N;";
const i18nLineIndex = source.indexOf(i18nLine);
if (fallbackStart === -1 || i18nLineIndex === -1 || i18nLineIndex < fallbackStart) {
return source;
}
return (
source.slice(0, fallbackStart)
+ " const I18N = readJsonScript('i18n') || (MOCK && MOCK.i18n) || {};\n"
+ source.slice(i18nLineIndex + i18nLine.length)
source.slice(0, fallbackStart) +
" const I18N = readJsonScript('i18n') || (MOCK && MOCK.i18n) || {};\n" +
source.slice(i18nLineIndex + i18nLine.length)
);
}
@@ -53,9 +47,12 @@ async function removeOldMinifiedAssets(assetDir, keepName) {
await Promise.all(
entries
.filter(
(entry) => entry.isFile() && /^subscription_webapp\.min\.[0-9a-f]{8}\.js$/.test(entry.name) && entry.name !== keepName,
(entry) =>
entry.isFile() &&
/^subscription_webapp\.min\.[0-9a-f]{8}\.js$/.test(entry.name) &&
entry.name !== keepName
)
.map((entry) => unlink(path.join(assetDir, entry.name))),
.map((entry) => unlink(path.join(assetDir, entry.name)))
);
}
@@ -64,7 +61,7 @@ async function main() {
const withoutMocks = stripMarkedBlock(
normalizeLineEndings(rawSource),
"/* WEBAPP_DEV_MOCK_START */",
"/* WEBAPP_DEV_MOCK_END */",
"/* WEBAPP_DEV_MOCK_END */"
);
const strippedSource = stripFallbackI18n(withoutMocks);
const result = await transform(strippedSource, {
@@ -77,14 +74,13 @@ async function main() {
const code = `${result.code.replace(/[ \t]+$/gm, "").trimEnd()}\n`;
const hash = createHash("sha256").update(code, "utf8").digest("hex").slice(0, 8);
const outputPath = path.join(
path.dirname(sourcePath),
`subscription_webapp.min.${hash}.js`,
);
const outputPath = path.join(path.dirname(sourcePath), `subscription_webapp.min.${hash}.js`);
await removeOldMinifiedAssets(path.dirname(sourcePath), path.basename(outputPath));
await writeFile(outputPath, code, "utf8");
console.log(`Wrote ${path.relative(repoRoot, outputPath)} (${Buffer.byteLength(code, "utf8")} bytes)`);
console.log(
`Wrote ${path.relative(repoRoot, outputPath)} (${Buffer.byteLength(code, "utf8")} bytes)`
);
}
await main();
+15
View File
@@ -0,0 +1,15 @@
# Запуск из корня репозитория: .\scripts\check-all.ps1
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSScriptRoot
Set-Location $root
Write-Host "Python: pip install -r requirements-dev.txt" -ForegroundColor Cyan
python -m pip install -q -r requirements-dev.txt
if (-not (Test-Path (Join-Path $root "node_modules"))) {
Write-Host "npm install (нет node_modules)" -ForegroundColor Cyan
npm install
}
Write-Host "npm run check" -ForegroundColor Cyan
npm run check
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
echo "Python: pip install -r requirements-dev.txt"
python -m pip install -q -r requirements-dev.txt
if [[ ! -d node_modules ]]; then
echo "npm install (no node_modules)"
npm install
fi
echo "npm run check"
npm run check
+4 -1
View File
@@ -7,6 +7,7 @@ Target chat (first match):
No default Telegram ID is embedded in this script.
"""
import asyncio
import os
import sys
@@ -19,7 +20,9 @@ from bot.utils.mini_app_url import subscription_mini_app_topup_url
from config.settings import Settings
def _premium_topup_markup(settings: Settings, i18n: JsonI18n, user_lang: str) -> InlineKeyboardMarkup:
def _premium_topup_markup(
settings: Settings, i18n: JsonI18n, user_lang: str
) -> InlineKeyboardMarkup:
_ = lambda k, **kw: i18n.gettext(user_lang, k, **kw)
url = subscription_mini_app_topup_url(settings, "premium")
if url: