Merge branch 'master' of github.com:fraction/oasis into npm-update-march-23
This commit is contained in:
commit
11c413d447
77
scripts/build.sh
Executable file
77
scripts/build.sh
Executable file
@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
BASEDIR="$(dirname "$0")"
|
||||
TARGET_VERSION="12.16.1"
|
||||
|
||||
cd "$BASEDIR/.."
|
||||
|
||||
git clean -fdx
|
||||
|
||||
mkdir -p vendor
|
||||
cd vendor
|
||||
|
||||
get_tgz () {
|
||||
TARGET_PLATFORM="$1"
|
||||
TARGET="node-v$TARGET_VERSION-$TARGET_PLATFORM-x64"
|
||||
ARCHIVE="$TARGET.tar.gz"
|
||||
URL="https://nodejs.org/dist/v$TARGET_VERSION/$ARCHIVE"
|
||||
TARGET_NODE="$TARGET/bin/node"
|
||||
|
||||
wget "$URL"
|
||||
tar -xvf "$ARCHIVE" "$TARGET_NODE"
|
||||
rm -f "$ARCHIVE"
|
||||
}
|
||||
|
||||
get_zip () {
|
||||
TARGET_PLATFORM="$1"
|
||||
TARGET="node-v$TARGET_VERSION-$TARGET_PLATFORM-x64"
|
||||
ARCHIVE="$TARGET.zip"
|
||||
URL="https://nodejs.org/dist/v$TARGET_VERSION/$ARCHIVE"
|
||||
TARGET_NODE="$TARGET/node.exe"
|
||||
|
||||
wget "$URL"
|
||||
unzip "$ARCHIVE" "$TARGET_NODE"
|
||||
rm -f "$ARCHIVE"
|
||||
}
|
||||
|
||||
get_tgz darwin
|
||||
get_tgz linux
|
||||
get_zip win
|
||||
|
||||
cd ..
|
||||
|
||||
# Avoid building anything from source.
|
||||
npm ci --only=prod --ignore-scripts --no-audit --no-fund
|
||||
# More trouble than it's worth :)
|
||||
rm -rf ./node_modules/sharp
|
||||
|
||||
export GOARCH="amd64"
|
||||
|
||||
# Darwin (shell script)
|
||||
export GOOS="darwin"
|
||||
OUTFILE="oasis-$GOOS-$GOARCH"
|
||||
go build -ldflags "-X main.node=vendor/node-v$TARGET_VERSION-darwin-x64/bin/node" -o "$OUTFILE" scripts/oasis.go
|
||||
chmod +x "$OUTFILE"
|
||||
|
||||
# Linux (ELF executable)
|
||||
export GOOS="linux"
|
||||
OUTFILE="oasis-$GOOS-$GOARCH"
|
||||
go build -ldflags "-X main.node=vendor/node-v$TARGET_VERSION-linux-x64/bin/node" -o "$OUTFILE" scripts/oasis.go
|
||||
chmod +x "$OUTFILE"
|
||||
|
||||
# Windows (batch file)
|
||||
export GOOS="windows"
|
||||
OUTFILE="oasis-$GOOS-$GOARCH.exe"
|
||||
go build -ldflags "-X main.node=vendor\\node-v$TARGET_VERSION-win-x64\\bin\\node" -o "$OUTFILE" scripts/oasis.go
|
||||
chmod +x "$OUTFILE"
|
||||
|
||||
# I think if the zip already exists it's adding files to the existing archive?
|
||||
ZIP_PATH="/tmp/oasis-x64.zip"
|
||||
|
||||
rm -f "$ZIP_PATH"
|
||||
zip -r "$ZIP_PATH" . -x ".git/**"
|
||||
|
||||
git clean -fdx
|
||||
|
57
scripts/oasis.go
Normal file
57
scripts/oasis.go
Normal file
@ -0,0 +1,57 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// The relative path to the `node` binary depends on the platform, so we
|
||||
// pass this via an `-ldflags` hack I don't completely understand. In my
|
||||
// head this is similar to how GCC lets you use `-D` to define a macro to
|
||||
// be inserted by the preprocessor.
|
||||
var node string
|
||||
|
||||
func main() {
|
||||
// The problem with relative paths is that they only work when
|
||||
// you run `./oasis-platform-x64`, but not when you run a command
|
||||
// like `./path/to/oasis-platform-x64`. To resolve this problem
|
||||
// we need to put together an absolute path, which we can build
|
||||
// with the first argument (the relative path of this executable)
|
||||
// and the relative path of either the `node` binary or the
|
||||
// source code directory so that we can run `node src`.
|
||||
node := filepath.Join(filepath.Dir(os.Args[0]), node)
|
||||
src := filepath.Join(filepath.Dir(os.Args[0]), "src")
|
||||
|
||||
// We know that the command will be the absolute path to `node`
|
||||
// and the first argument will be the absolute path to the `src`
|
||||
// directory, but we need to get collect the rest of the arguments
|
||||
// programatically by pulling them out of the `os.Args` slice and
|
||||
// putting them in a new slice called `args`.
|
||||
args := []string{src}
|
||||
for i := 1; i < len(os.Args); i++ {
|
||||
args = append(args, os.Args[i])
|
||||
}
|
||||
|
||||
// This seems to execute the script and pass-through all of the
|
||||
// arguments we want, *plus* it hooks up stdout and stderr, but
|
||||
// the exit code of Oasis doesn't seem to be passed through. This
|
||||
// is easy to test with a command like:
|
||||
//
|
||||
// ./oasis-platform-x64 --port -1
|
||||
//
|
||||
// This should give an exit code of 1, but it seems to exit 0. :/
|
||||
cmd := exec.Command(node, args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
// This catches problems like "no such file or directory" if the
|
||||
// `node` variable points to a path where there isn't a binary.
|
||||
//
|
||||
// TODO: I think we're supposed to handle the exit code here.
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
@ -43,4 +43,9 @@ module.exports = (presets, defaultConfigFile) =>
|
||||
default: _.get(presets, "debug", false),
|
||||
type: "boolean",
|
||||
})
|
||||
.options("theme", {
|
||||
describe: "The theme to use, if a theme hasn't been set in the cookies",
|
||||
default: _.get(presets, "theme", "atelier-sulphurPool-light"),
|
||||
type: "string",
|
||||
})
|
||||
.epilog(`The defaults can be configured in ${defaultConfigFile}.`).argv;
|
||||
|
@ -173,8 +173,6 @@ try {
|
||||
// Optional dependency
|
||||
}
|
||||
|
||||
const defaultTheme = "atelier-sulphurPool-light".toLowerCase();
|
||||
|
||||
const readmePath = path.join(__dirname, "..", "README.md");
|
||||
const packagePath = path.join(__dirname, "..", "package.json");
|
||||
|
||||
@ -320,7 +318,7 @@ router
|
||||
ctx.body = await hashtagView({ hashtag, messages });
|
||||
})
|
||||
.get("/theme.css", (ctx) => {
|
||||
const theme = ctx.cookies.get("theme") || defaultTheme;
|
||||
const theme = ctx.cookies.get("theme") || config.theme;
|
||||
|
||||
const packageName = "@fraction/base16-css";
|
||||
const filePath = `${packageName}/src/base16-${theme}.css`;
|
||||
@ -500,7 +498,7 @@ router
|
||||
ctx.body = await image({ blobId, imageSize: Number(imageSize) });
|
||||
})
|
||||
.get("/settings/", async (ctx) => {
|
||||
const theme = ctx.cookies.get("theme") || defaultTheme;
|
||||
const theme = ctx.cookies.get("theme") || config.theme;
|
||||
const getMeta = async ({ theme }) => {
|
||||
const status = await meta.status();
|
||||
const peers = await meta.peers();
|
||||
|
@ -1055,17 +1055,22 @@ module.exports = ({ cooler, isPublic }) => {
|
||||
debug("getting root ancestor of %s", msg.key);
|
||||
|
||||
if (typeof msg.value.content === "string") {
|
||||
debug("private message");
|
||||
// Private message we can't decrypt, stop looking for parents.
|
||||
resolve(parents);
|
||||
}
|
||||
|
||||
if (msg.value.content.type !== "post") {
|
||||
debug("private message");
|
||||
if (parents.length > 0) {
|
||||
// If we already have some parents, return those.
|
||||
resolve(parents);
|
||||
} else {
|
||||
// If we don't know of any parents, resolve this message.
|
||||
resolve(msg);
|
||||
}
|
||||
} else if (msg.value.content.type !== "post") {
|
||||
debug("not a post");
|
||||
resolve(msg);
|
||||
}
|
||||
|
||||
if (isLooseReply(msg) && ssbRef.isMsg(msg.value.content.fork)) {
|
||||
} else if (
|
||||
isLooseReply(msg) &&
|
||||
ssbRef.isMsg(msg.value.content.fork)
|
||||
) {
|
||||
debug("reply, get the parent");
|
||||
try {
|
||||
// It's a message reply, get the parent!
|
||||
|
@ -125,7 +125,7 @@ module.exports = {
|
||||
],
|
||||
theme: "Theme",
|
||||
themeIntro:
|
||||
"Choose from any theme you'd like. The default theme is Atelier-SulphurPool-Light.",
|
||||
"Choose from any theme you'd like. The default theme is Atelier-SulphurPool-Light. You can also set your theme in the default configuration file.",
|
||||
setTheme: "Set theme",
|
||||
language: "Language",
|
||||
languageDescription:
|
||||
|
Loading…
Reference in New Issue
Block a user