From fedcc8d25d58cde0fe723b8f2c93d3d3e21463c5 Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Wed, 28 Jan 2026 05:29:56 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20Simplify=20argument=20p?= =?UTF-8?q?arsing=20and=20validation=20logic=20by=20removing=20redundant?= =?UTF-8?q?=20type=20annotations=20and=20relocating=20target=20validation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/utils/deploy-pokedex.js | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/code/utils/deploy-pokedex.js b/code/utils/deploy-pokedex.js index fce537a..259b592 100644 --- a/code/utils/deploy-pokedex.js +++ b/code/utils/deploy-pokedex.js @@ -29,16 +29,6 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); // Configuration -/** - * @typedef {Object} SSHHostConfig - * @property {string} host - * @property {number} port - * @property {string} username - * @property {string} privateKeyPath - * @property {string} password - */ - -/** @type {Record<'internal'|'external', SSHHostConfig>} */ const SSH_HOSTS = { internal: { host: '10.0.0.81', @@ -65,12 +55,8 @@ const DIST_DIR = path.join(SOURCE_DIR, 'dist'); * Parse command line arguments * @returns {Object} Parsed arguments */ -/** - * @returns {{ target: keyof typeof SSH_HOSTS, port: number, sslPort: number|null }} - */ function parseArgs() { const args = process.argv.slice(2); - /** @type {{ target: keyof typeof SSH_HOSTS, port: number, sslPort: number|null }} */ const config = { target: 'internal', port: 8080, @@ -79,15 +65,7 @@ function parseArgs() { for (let i = 0; i < args.length; i++) { if (args[i] === '--target' && args[i + 1]) { - /** @type {any} */ - const t = args[i + 1]; - if (t === 'internal' || t === 'external') { - config.target = t; - } else { - throw new Error( - `Invalid target: ${t}. Must be 'internal' or 'external'.` - ); - } + config.target = args[i + 1]; i++; } else if (args[i] === '--port' && args[i + 1]) { config.port = parseInt(args[i + 1], 10); @@ -98,6 +76,13 @@ function parseArgs() { } } + // Validate target + if (!SSH_HOSTS[config.target]) { + throw new Error( + `Invalid target: ${config.target}. Must be 'internal' or 'external'.` + ); + } + // Validate port if (isNaN(config.port) || config.port < 1 || config.port > 65535) { throw new Error(