Skip to content

Commit

Permalink
chore updates to eternity template.
Browse files Browse the repository at this point in the history
  • Loading branch information
ispyhumanfly committed Nov 4, 2023
1 parent 5a39d4b commit 0028120
Show file tree
Hide file tree
Showing 6 changed files with 395 additions and 115 deletions.
15 changes: 11 additions & 4 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ export class Network {}
* User
* @summary Some basic user utils. More to follow.
*/
export class User extends Iniquity {
export class User {
public name = ""
public password = ""

Expand All @@ -822,21 +822,28 @@ export class User extends Iniquity {
* @param options
*/
constructor(options: IUserOptions) {
super()
this.name = options.name
this.password = options.password
}

login() {
const user = bbs.login(this.name, null, this.password)
if (user) return user
else return undefined
}

exists(): boolean {

const user = bbs.login(this.name)
if (user) return true
else return false
}

new() {
const user = system.new_user(this.name)
// TODO check for all return properties of this sbbs system.new_user
const user = system.new_user(this.name) as { password: string }
if (user) {
say(JSON.stringify(user)).pause()
// @ts-expect-error
user.password = this.password
}

Expand Down
3 changes: 2 additions & 1 deletion packages/iniquity/src/commands/index.ts
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 }
164 changes: 164 additions & 0 deletions packages/iniquity/src/commands/update.ts
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()
89 changes: 0 additions & 89 deletions packages/templates/src/eternity/assets/mailtop.ans

This file was deleted.

Loading

0 comments on commit 0028120

Please sign in to comment.