fix: run prettier & remove unused fragments

This commit is contained in:
divocat
2025-10-07 00:50:39 +03:00
parent 7cb43ffb65
commit c78f97d64f
5 changed files with 283 additions and 301 deletions

View File

@@ -1,6 +1,5 @@
import { ValidationResult } from './types'; import { ValidationResult } from './types';
// TODO refactor current validation and add tests
export function validateVlessUrl(url: string): ValidationResult { export function validateVlessUrl(url: string): ValidationResult {
try { try {
const parsedUrl = new URL(url); const parsedUrl = new URL(url);

View File

@@ -23,12 +23,12 @@ async function uploadFile(filePath) {
const relativePath = path.relative(localDir, filePath); const relativePath = path.relative(localDir, filePath);
const remotePath = path.posix.join(remoteDir, relativePath); const remotePath = path.posix.join(remoteDir, relativePath);
console.log(`⬆️ Uploading: ${relativePath} -> ${remotePath}`); console.log(`Uploading: ${relativePath} -> ${remotePath}`);
try { try {
await sftp.fastPut(filePath, remotePath); await sftp.fastPut(filePath, remotePath);
console.log(`Uploaded: ${relativePath}`); console.log(`Uploaded: ${relativePath}`);
} catch (err) { } catch (err) {
console.error(`Failed: ${relativePath}: ${err.message}`); console.error(`Failed: ${relativePath}: ${err.message}`);
} }
} }
@@ -36,34 +36,32 @@ async function deleteFile(filePath) {
const relativePath = path.relative(localDir, filePath); const relativePath = path.relative(localDir, filePath);
const remotePath = path.posix.join(remoteDir, relativePath); const remotePath = path.posix.join(remoteDir, relativePath);
console.log(`🗑 Removing: ${relativePath}`); console.log(`Removing: ${relativePath}`);
try { try {
await sftp.delete(remotePath); await sftp.delete(remotePath);
console.log(`Removed: ${relativePath}`); console.log(`Removed: ${relativePath}`);
} catch (err) { } catch (err) {
console.warn(`⚠️ Could not delete ${relativePath}: ${err.message}`); console.warn(`Could not delete ${relativePath}: ${err.message}`);
} }
} }
async function uploadAllFiles() { async function uploadAllFiles() {
console.log('🚀 Uploading all files from', localDir); console.log('Uploading all files from', localDir);
const files = await glob(`${localDir}/**/*`, { nodir: true }); const files = await glob(`${localDir}/**/*`, { nodir: true });
for (const file of files) { for (const file of files) {
await uploadFile(file); await uploadFile(file);
} }
console.log('Initial upload complete!'); console.log('Initial upload complete!');
} }
async function main() { async function main() {
await sftp.connect(config); await sftp.connect(config);
console.log(`Connected to ${config.host}`); console.log(`Connected to ${config.host}`);
// 🔹 Загрузить всё при старте
await uploadAllFiles(); await uploadAllFiles();
// 🔹 Затем следить за изменениями
chokidar chokidar
.watch(localDir, { ignoreInitial: true }) .watch(localDir, { ignoreInitial: true })
.on('all', async (event, filePath) => { .on('all', async (event, filePath) => {
@@ -75,7 +73,7 @@ async function main() {
}); });
process.on('SIGINT', async () => { process.on('SIGINT', async () => {
console.log('🔌 Disconnecting...'); console.log('Disconnecting...');
await sftp.end(); await sftp.end();
process.exit(); process.exit();
}); });

View File

@@ -13,14 +13,14 @@ function createDashboardSection(mainSection) {
o = mainSection.taboption('dashboard', form.DummyValue, '_status'); o = mainSection.taboption('dashboard', form.DummyValue, '_status');
o.rawhtml = true; o.rawhtml = true;
o.cfgvalue = () => { o.cfgvalue = () => {
main.initDashboardController() main.initDashboardController();
return main.renderDashboard() return main.renderDashboard();
}; };
} }
const EntryPoint = { const EntryPoint = {
createDashboardSection, createDashboardSection,
} };
return baseclass.extend(EntryPoint); return baseclass.extend(EntryPoint);

View File

@@ -13,21 +13,6 @@ const EntryNode = {
async render() { async render() {
main.injectGlobalStyles(); main.injectGlobalStyles();
// main.getClashVersion()
// .then(result => console.log('getClashVersion - then', result))
// .catch(err => console.log('getClashVersion - err', err))
// .finally(() => console.log('getClashVersion - finish'));
//
// main.getClashConfig()
// .then(result => console.log('getClashConfig - then', result))
// .catch(err => console.log('getClashConfig - err', err))
// .finally(() => console.log('getClashConfig - finish'));
//
// main.getClashProxies()
// .then(result => console.log('getClashProxies - then', result))
// .catch(err => console.log('getClashProxies - err', err))
// .finally(() => console.log('getClashProxies - finish'));
const podkopFormMap = new form.Map('podkop', '', null, ['main', 'extra']); const podkopFormMap = new form.Map('podkop', '', null, ['main', 'extra']);
// Main Section // Main Section
@@ -41,7 +26,7 @@ const EntryNode = {
// Diagnostics Tab (main section) // Diagnostics Tab (main section)
diagnosticTab.createDiagnosticsSection(mainSection); diagnosticTab.createDiagnosticsSection(mainSection);
const podkopFormMapPromise = podkopFormMap.render().then(node => { const podkopFormMapPromise = podkopFormMap.render().then((node) => {
// Set up diagnostics event handlers // Set up diagnostics event handlers
diagnosticTab.setupDiagnosticsEventHandlers(node); diagnosticTab.setupDiagnosticsEventHandlers(node);
@@ -73,25 +58,25 @@ const EntryNode = {
}); });
// Extra Section // Extra Section
const extraSection = podkopFormMap.section(form.TypedSection, 'extra', _('Extra configurations')); const extraSection = podkopFormMap.section(
form.TypedSection,
'extra',
_('Extra configurations'),
);
extraSection.anonymous = false; extraSection.anonymous = false;
extraSection.addremove = true; extraSection.addremove = true;
extraSection.addbtntitle = _('Add Section'); extraSection.addbtntitle = _('Add Section');
extraSection.multiple = true; extraSection.multiple = true;
configSection.createConfigSection(extraSection); configSection.createConfigSection(extraSection);
// Initial dashboard render // Initial dashboard render
dashboardTab.createDashboardSection(mainSection); dashboardTab.createDashboardSection(mainSection);
// Inject dashboard actualizer logic
// main.initDashboardController();
// Inject core service // Inject core service
main.coreService(); main.coreService();
return podkopFormMapPromise; return podkopFormMapPromise;
} },
} };
return view.extend(EntryNode); return view.extend(EntryNode);