-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
@@ -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 { | ||
|
@@ -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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters