-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
5a39d4b
commit 0028120
Showing
6 changed files
with
395 additions
and
115 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
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 @@ | ||
import init from "./init" | ||
import term from "./term" | ||
import server from "./server" | ||
import update from "./update" | ||
|
||
export { init, term, server } | ||
export { init, term, server, update } |
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,164 @@ | ||
/** | ||
* | ||
* Iniquity Update | ||
* @summary The super cool command line interface to Iniquity. | ||
* @example Invoking via the shell | ||
* ```shell | ||
* iq update --help | ||
* ``` | ||
* @example Invoking via yargs programatically | ||
* ```typescript | ||
* import Update from "@iniquitybbs/iniquity/src/commands/update" | ||
* const update: yargs.CommandModule = new Update() | ||
* ``` | ||
*/ | ||
|
||
/* | ||
-$a. ------------------ .a$ ---------------------------- %$!, ----------------% | ||
`$¸ .%$$^¸$$aa. .¸$` . .a$a$$. `¸$% $a$. . | ||
-.aaa$ $$$$'- $$$$$.- $aaa. -.a%$^"$$aa -- .$$$$$'- $$a. $aaa. `$,$ ----------% | ||
;$$$$',a$a$ d$%$$$$$,'$$$$;$$$$$ $$$$$., $$%$$" d$a$$ '$$$$; $$$ .a%$ $$a | ||
:$$$$;$$$$%; Z$$$$$$$$;$$$$:$$$$$. $$$$^$,;$$&$$ Z$$$$,;$$$$.a$$$a..$$$ $$$ | ||
.$$$$ `$$$$. $$$%$$$' $$$$.`$$$$ $$%$$$$ `$$$$. $%$$$ $$$$""$$$" $$$$: a$$ | ||
`$$$a.$$%$ $$$$$$';a$$$` `¸$$aa$$$$&$': `$$$$a. $$$$'a$$$`.$$'$ $$$$; $$$ | ||
%-----.------ $$$$'--------------- $$%$$' -- `¸$$$$$%$¸' ---- $$¸$a. `"$&$$//$%$ | ||
dz . .:'¸' . . $$$$' . . `¸$$$$y. `$$& | ||
%--------- a`-----------.--------- $$¸' -----.------------.---------------- $$$ | ||
. !a . . . . .:' . . . .:.a$$$¸ | ||
. . '$a, . a` . 'a . . s` . . . | ||
. ¸$Aa . !a a! . . .. %s .s | ||
. ¸¸' . . '$$Aa.aA$$' . . `!$%a.a%//$ | ||
============================================================================== | ||
t h e i n i q u i t y b u l l e t i n b o a r d s y s t e m | ||
============================================================================== | ||
*/ | ||
|
||
import yargs from "yargs" | ||
import * as path from "path" | ||
import fs from "fs" | ||
import { exec } from "child_process" | ||
|
||
import * as compose from "docker-compose" | ||
import * as dotenv from "dotenv" | ||
import copyfiles from "copyfiles" | ||
dotenv.config() | ||
|
||
process.env["COMPOSE_PROJECT_NAME"] = "iniquity" | ||
process.env["COMPOSE_HTTP_TIMEOUT"] = process.env["COMPOSE_HTTP_TIMEOUT"] || "120" | ||
process.env["COMPOSE_INTERACTIVE_NO_CLI"] = "true" | ||
|
||
const composeOptions: compose.IDockerComposeOptions = { | ||
composeOptions: ["-f", path.join(".iniquity/docker-compose.yml") || process.env["COMPOSE_FILE"] || ""], | ||
log: true, | ||
env: process.env | ||
} | ||
|
||
/** | ||
* Iniquity Update | ||
* @summary The main entry into all iniquity cli commands that are available. | ||
* @implements {yargs.CommandModule} | ||
*/ | ||
export class Update implements yargs.CommandModule { | ||
public command = "server [action]" | ||
public describe = "Control your iniquity bbs server." | ||
|
||
public builder = (yargs: yargs.Argv) => { | ||
return yargs | ||
.options("install", { | ||
type: "boolean", | ||
default: false, | ||
describe: "Install dependencies for the iniquity bbs app." | ||
}) | ||
.options("watch", { | ||
type: "boolean", | ||
default: false, | ||
describe: "Watch for changes in the iniquity bbs app." | ||
}) | ||
.positional("start", { | ||
type: "string", | ||
description: "Starts the iniquity bbs app on this machine." | ||
}) | ||
.positional("stop", { | ||
type: "string", | ||
description: "Brings the iniquity bbs environment down." | ||
}) | ||
.positional("restart", { | ||
type: "string", | ||
description: "Restart your iniquity bbs environment." | ||
}) | ||
.pkgConf("iniquity", path.join(__dirname)) | ||
} | ||
public handler(argv: yargs.Arguments) { | ||
if (argv.install || argv.watch) { | ||
if (fs.existsSync(".iniquity")) { | ||
process.chdir(".iniquity") | ||
|
||
if (argv.install) { | ||
exec("npm install", (err, stdout, stderr) => { | ||
if (err) { | ||
console.error(err) | ||
return | ||
} | ||
|
||
console.log(stdout) | ||
}) | ||
} | ||
|
||
if (argv.watch) { | ||
copyfiles([path.join(".", "./assets/*"), ".iniquity/dist/assets"], { up: true, all: true }, (err) => { | ||
// console.error(err) | ||
}) | ||
|
||
exec("npx rollup -cw", (err, stdout, stderr) => { | ||
if (err) { | ||
console.error(err) | ||
return | ||
} | ||
|
||
console.log(stdout) | ||
}) | ||
} | ||
|
||
process.chdir("../") | ||
} | ||
} | ||
|
||
switch (argv.action) { | ||
case "start": | ||
compose.upAll(composeOptions).then( | ||
(response: compose.IDockerComposeResult) => { | ||
if (response.out) console.log(response.out) | ||
}, | ||
(err) => { | ||
console.error("something went wrong:", err) | ||
} | ||
) | ||
|
||
break | ||
case "stop": | ||
compose.down(composeOptions).then( | ||
(response: compose.IDockerComposeResult) => { | ||
if (response.out) console.log(response.out) | ||
}, | ||
(err) => { | ||
console.error("something went wrong:", err) | ||
} | ||
) | ||
|
||
break | ||
case "restart": | ||
compose.restartOne("server", composeOptions).then( | ||
(response: compose.IDockerComposeResult) => { | ||
if (response.out) console.log(response.out) | ||
}, | ||
(err) => { | ||
console.error("something went wrong:", err) | ||
} | ||
) | ||
|
||
break | ||
} | ||
} | ||
} | ||
|
||
export default new Update() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.