Skip to content

Commit

Permalink
deploy structure
Browse files Browse the repository at this point in the history
  • Loading branch information
dev2-nomo committed Nov 22, 2023
1 parent 29d774e commit 0f871b7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
35 changes: 30 additions & 5 deletions src/util/ssh-manager.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { logFatal, readCliConfig, runCommandsSequentially } from "../util/util";
import {
extractAndCache,
getCachedIndexHtmlPath,
getCachedNomoIconPath,
getCachedNomoManifestPath,
} from "../util/extract-tar-gz";
import { NomoManifest } from "../init/interface";
import * as fs from "fs";
import { validateManifest } from "../util/validate-manifest";
import * as path from "path";

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

export async function connectToSSH(args: {
deployTarget: string;
Expand All @@ -29,17 +32,22 @@ 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,
});
const manifestPath = getCachedNomoManifestPath();

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

await runCommandsSequentially(commands);

const iconPath = getCachedNomoIconPath();
}

function ls(): string {
Expand All @@ -51,6 +59,23 @@ function checkCreateDir(sshBaseDir: string): string {
return `${sshConnect} "${mkdirCommand}"`;
}

function deployFile(filePath: string, sshBaseDir: string): string {
const absolutePath = path.resolve(filePath);

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

return scpCommand;
}
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 manifestChecks(manifestFilePath: string) {
const nomoManifestContent = fs.readFileSync(manifestFilePath, "utf-8");
const nomoManifest: NomoManifest = JSON.parse(nomoManifestContent);
Expand Down
4 changes: 2 additions & 2 deletions src/util/validate-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export async function validateManifest(manifest: NomoManifest): Promise<void> {
// `min_nomo_version ${minNomoVersion} does not comply with semantic versioning regexp`
// );
// }
// Assume you have a function similar to versionTwoGreaterThanVersionOne
const currentVersion = "0.1.0";

const currentVersion = "0.0.0";
// TODO: set the currentVersion to manifest.webon_version and compare it to the manifest version from server
console.log("currentVersion: " + currentVersion);
console.log("webOnversion" + webOnVersion);
Expand Down

0 comments on commit 0f871b7

Please sign in to comment.