-
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.
chore: code restructure & commandParser tests
- Loading branch information
Johan
committed
Sep 16, 2019
1 parent
803afbe
commit f09ec80
Showing
25 changed files
with
239 additions
and
124 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,5 +1,6 @@ | ||
dist | ||
src/common/ssh/.ssh.config.json | ||
src/lib/ssh/.ssh.config.json | ||
package | ||
.DS_STORE | ||
|
||
# Logs | ||
|
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,3 +1,3 @@ | ||
{ | ||
"debug.node.autoAttach": "on" | ||
"debug.node.autoAttach": "off" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import cli from "../lib/cli"; | ||
|
||
process.once("uncaughtException", err => { | ||
console.error(err.stack); | ||
|
||
process.exitCode = 2; | ||
}); | ||
|
||
cli.run(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env node | ||
import ssh from "../../ssh"; | ||
|
||
const firewall = (args: string[]): void => { | ||
const firewallArgs = (args || []).join(" "); | ||
const interactive = firewallArgs === ""; | ||
|
||
const command = "sh /jffs/scripts/firewall"; | ||
|
||
if (interactive) { | ||
ssh.executeInTerminal(command); | ||
} else { | ||
ssh.execute(`${command} ${firewallArgs}`); | ||
} | ||
}; | ||
|
||
export default { | ||
run: firewall, | ||
helpname: "firewall [args]", | ||
description: "Opens the Skynet firewall with the passes args (optional)" | ||
}; |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/commands/firewall/log/transfer.ts → src/lib/commands/firewall/log/transfer.ts
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
2 changes: 1 addition & 1 deletion
2
src/commands/info/commands.ts → src/lib/commands/info/commands.ts
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
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
src/commands/info/uptime.ts → src/lib/commands/info/uptime.ts
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
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
File renamed without changes.
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env node | ||
import { existsSync, readFileSync } from "fs"; | ||
import { join } from "path"; | ||
|
||
import sh from "shelljs"; | ||
|
||
const getConfig = () => { | ||
const sshConfigFile = join(__dirname, ".ssh.config.json"); | ||
|
||
let config = { | ||
host: "n/a", | ||
username: "n/a", | ||
privateKey: "n/a" | ||
}; | ||
|
||
if (existsSync(sshConfigFile)) { | ||
config = JSON.parse(readFileSync(sshConfigFile, "utf8")); | ||
} | ||
|
||
return config; | ||
}; | ||
|
||
const execute = (...args: string[]): void => { | ||
const config = getConfig(); | ||
|
||
const ssh = `ssh -i '${config.privateKey}' ${config.username}@${config.host}`; | ||
|
||
sh.exec(`${ssh} "${args.join(" ")}"`); | ||
}; | ||
|
||
const executeInTerminal = (args: any) => { | ||
const config = getConfig(); | ||
|
||
const ssh = `ssh -i '${config.privateKey}' ${config.username}@${config.host}`; | ||
|
||
sh.exec(`osascript -e 'tell app "Terminal" | ||
activate | ||
do script "${ssh} ${args}" | ||
end tell'`); | ||
}; | ||
|
||
export default { execute, executeInTerminal }; |
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
Oops, something went wrong.