Skip to content

Commit

Permalink
Fixed pathing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dev2-nomo committed Nov 21, 2023
1 parent 443fae8 commit e6d3a65
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
41 changes: 29 additions & 12 deletions src/deploy-webon/deploy-webon.ts
Original file line number Diff line number Diff line change
@@ -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}`);
}
}
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ function commanderBuildWebOn() {
function commanderInitWebOn() {
commander
.command("init <assetDir>")
.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 });
Expand All @@ -33,11 +35,11 @@ function commanderInitWebOn() {

function commanderDeployWebOn() {
commander
.command("deploy <archive>")
.command("deploy <archive> <deployTarget>")
.description("Deploy a WebOn archive")
.action((archive) => {
.action((archive, deployTarget) => {
runAsyncCommand(async () => {
await deployWebOn({ archive });
await deployWebOn({ archive, deployTarget });
});
});
}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"pretty": true,
"target": "es2019",
"strict": true,
"allowJs": true,
},
"files": [
"src/index.ts"
Expand Down

0 comments on commit e6d3a65

Please sign in to comment.