From e6d3a65f4394a675d85dddda11450b2981241134 Mon Sep 17 00:00:00 2001 From: dev-ig Date: Tue, 21 Nov 2023 11:39:55 +0100 Subject: [PATCH] Fixed pathing errors --- src/deploy-webon/deploy-webon.ts | 41 ++++++++++++++++++++++---------- src/index.ts | 10 ++++---- tsconfig.json | 1 + 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/deploy-webon/deploy-webon.ts b/src/deploy-webon/deploy-webon.ts index 951bfd5..4a95d7f 100644 --- a/src/deploy-webon/deploy-webon.ts +++ b/src/deploy-webon/deploy-webon.ts @@ -1,30 +1,47 @@ import { checkNotDir, logFatal } from "../util/util"; -import { nomoCliConfig } from "../../nomo_cli.config"; +import { nomoCliConfig } from "../../nomo_cli.config.js"; + +function isDeployTarget( + target: string +): target is keyof typeof nomoCliConfig.deployTargets { + return target in nomoCliConfig.deployTargets; +} export async function deployWebOn(args: { deployTarget: string; archive: string; }) { const { deployTarget, archive } = args; - checkNotDir(archive); - const targetConfig = nomoCliConfig.deployTargets[deployTarget]; + if (!isDeployTarget(deployTarget)) { + logFatal(`Invalid deployTarget: ${deployTarget}`); + return; + } + const targetConfig = nomoCliConfig.deployTargets[deployTarget]; if (!targetConfig) { logFatal(`Invalid deployTarget: ${deployTarget}`); return; } const { rawSSH } = targetConfig; - const { sshHost, sshBaseDir, publicBaseUrl, sshPort } = rawSSH; - // Use the deployment configuration to perform the deployment logic - // Replace this with your actual deployment logic - console.log(`Deploying to ${deployTarget}...`); - console.log(`SSH Host: ${sshHost}`); - console.log(`SSH Base Directory: ${sshBaseDir}`); - console.log(`Public Base URL: ${publicBaseUrl}`); - console.log(`SSH Port: ${sshPort || "default"}`); - console.log(`Archive Path: ${archive}`); + if ("sshPort" in rawSSH) { + const { sshHost, sshBaseDir, publicBaseUrl, sshPort } = rawSSH; + console.log(`Deploying to ${deployTarget}...`); + console.log(`SSH Host: ${sshHost}`); + console.log(`SSH Base Directory: ${sshBaseDir}`); + console.log(`Public Base URL: ${publicBaseUrl}`); + console.log(`SSH Port: ${sshPort}`); + console.log(`Archive Path: ${archive}`); + } else { + const { sshHost, sshBaseDir, publicBaseUrl } = rawSSH; + console.log(`Deploying to ${deployTarget}...`); + console.log(`SSH Host: ${sshHost}`); + console.log(`SSH Base Directory: ${sshBaseDir}`); + console.log(`Public Base URL: ${publicBaseUrl}`); + console.log("SSH Port is not specified"); + console.log(`Archive Path: ${archive}`); + } } diff --git a/src/index.ts b/src/index.ts index 5448f56..8bcc603 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,9 @@ function commanderBuildWebOn() { function commanderInitWebOn() { commander .command("init ") - .description("Init nomo-webon-cli, create configs and manifest if not existing.") + .description( + "Init nomo-webon-cli, create configs and manifest if not existing." + ) .action((assetDir) => { runAsyncCommand(async () => { await init({ assetDir }); @@ -33,11 +35,11 @@ function commanderInitWebOn() { function commanderDeployWebOn() { commander - .command("deploy ") + .command("deploy ") .description("Deploy a WebOn archive") - .action((archive) => { + .action((archive, deployTarget) => { runAsyncCommand(async () => { - await deployWebOn({ archive }); + await deployWebOn({ archive, deployTarget }); }); }); } diff --git a/tsconfig.json b/tsconfig.json index 50f73fe..3344c1f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,6 +14,7 @@ "pretty": true, "target": "es2019", "strict": true, + "allowJs": true, }, "files": [ "src/index.ts"