Skip to content

Commit

Permalink
successful deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
dev2-nomo committed Nov 23, 2023
1 parent 0f871b7 commit 6c086cc
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions src/util/ssh-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { validateManifest } from "../util/validate-manifest";
import * as path from "path";

let sshConnect = "";
let sshConnectForce = "";
const manifestPath = getCachedNomoManifestPath();
const iconPath = getCachedNomoIconPath();

Expand All @@ -32,19 +31,18 @@ export async function connectToSSH(args: {
const { sshHost, sshBaseDir, publicBaseUrl, sshPort } = rawSSH;
const portOption = sshPort ? `-p ${sshPort}` : "";
sshConnect = `ssh -t ${sshHost} ${portOption}`;
sshConnectForce = `ssh -T ${sshHost} ${portOption}`;

await extractAndCache({
tarFilePath: archive,
});

manifestChecks(manifestPath);
const commands = [
// ls(),
// checkCreateDir(sshBaseDir),
deployFile(archive, sshBaseDir),
// deployFile(manifestPath, sshBaseDir),
// deployFile(iconPath, sshBaseDir),
ls(),
checkCreateDir(sshBaseDir),
deployFile(archive, sshHost, sshBaseDir, sshPort),
deployFile(manifestPath, sshHost, sshBaseDir, sshPort),
deployFile(iconPath, sshHost, sshBaseDir, sshPort),
];

await runCommandsSequentially(commands);
Expand All @@ -59,22 +57,26 @@ function checkCreateDir(sshBaseDir: string): string {
return `${sshConnect} "${mkdirCommand}"`;
}

function deployFile(filePath: string, sshBaseDir: string): string {
function scpCommand(
filePath: string,
sshHost: string,
sshBaseDir: string,
port?: number
): string {
const absolutePath = path.resolve(filePath);

const scpCommand = `${sshConnectForce} 'scp ${absolutePath} ${sshBaseDir}'`;

return scpCommand;
return `scp ${
port ? `-P ${port}` : ""
} ${absolutePath} ${sshHost}:${sshBaseDir}`;
}
function deployFile2(filePath: string, sshBaseDir: string): string {
// const portOption = rawSSH.sshPort ? `-P ${rawSSH.sshPort}` : '';
//const sshKeyOption = rawSSH.sshKey ? `-i ${rawSSH.sshKey}` : '';
//const scpCommand = `scp ${sshKeyOption} ${portOption} ${filePath} ${rawSSH.sshHost}:${sshBaseDir}`;
// return scpCommand;
}
//"scp -i /path/to/private/key -P 51110 /Users/ilijaGlavas/StudioProjects/nomo-webon-cli/out/nomo.tar.gz [email protected]:/var/www/html/webons/demo.nomo.app/

//("scp -p 51110 /Users/ilijaGlavas/StudioProjects/nomo-webon-cli/out/nomo.tar.gz [email protected]:/var/www/html/webons/demo.nomo.app/");
function deployFile(
filePath: string,
sshHost: string,
sshBaseDir: string,
port?: number
): string {
return `${scpCommand(filePath, sshHost, sshBaseDir, port)}`;
}

function manifestChecks(manifestFilePath: string) {
const nomoManifestContent = fs.readFileSync(manifestFilePath, "utf-8");
Expand Down

0 comments on commit 6c086cc

Please sign in to comment.