Some initial progress

This commit is contained in:
Radon Rosborough 2020-12-17 19:04:02 -08:00
parent ceb88d65ad
commit 2759e4df69
11 changed files with 166 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.log
node_modules

9
Makefile Normal file
View File

@ -0,0 +1,9 @@
export PATH := bin:$(PATH)
.PHONY: build-image
build-image:
docker build . -f docker/Dockerfile.build -t riju:build
.PHONY: build-shell
build-shell: build-image
docker run -it --rm -v $(PWD):/src riju:build

9
bin/docker Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ "${OSTYPE:-}" != darwin* ]] && [[ "${EUID}" != 0 ]]; then
exec sudo -E docker "$@"
else
exec docker "$@"
fi

0
build/build.js Normal file
View File

28
build/debug.js Normal file
View File

@ -0,0 +1,28 @@
const fs = require("fs").promises;
const process = require("process");
const YAML = require("yaml");
async function main() {
const args = process.argv.slice(2);
if (args.length !== 1) {
console.error("usage: debug.js LANG");
process.exit(1);
}
const [lang] = args;
console.log(
JSON.stringify(
YAML.parse(await fs.readFile(`langs/${lang}.yaml`, "utf-8")),
null,
2
)
);
}
main().catch((err) => {
console.error(err);
process.exit(1);
});

9
docker/Dockerfile.build Normal file
View File

@ -0,0 +1,9 @@
FROM ubuntu:rolling
COPY docker/scripts/build/install.bash /tmp/
RUN /tmp/install.bash
WORKDIR /src
COPY docker/scripts/build/pid1.bash /usr/local/sbin/
ENTRYPOINT ["/usr/local/sbin/pid1.bash"]
CMD ["bash"]

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -euxo pipefail
export DEBIAN_FRONTEND=noninteractive
apt-get update
(yes || true) | unminimize
apt-get install -y curl gnupg lsb-release
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
ubuntu_ver="$(lsb_release -rs)"
ubuntu_name="$(lsb_release -cs)"
node_repo="$(curl -sS https://deb.nodesource.com/setup_current.x | grep NODEREPO= | grep -Eo 'node_[0-9]+\.x' | head -n1)"
tee -a /etc/apt/sources.list.d/custom.list >/dev/null <<EOF
deb https://deb.nodesource.com/${node_repo} ${ubuntu_name} main
deb https://dl.yarnpkg.com/debian/ stable main
EOF
apt-get update
apt-get install -y fakeroot less make man nodejs yarn
rm -rf /var/lib/apt/lists/*
rm "$0"

8
docker/scripts/build/pid1.bash Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
groupadd -g "$(stat -c %g "$PWD")" -o -p '!' -r riju
useradd -u "$(stat -c %u "$PWD")" -g "$(stat -c %g "$PWD")" -o -m -N -l -s /usr/bin/bash riju
exec runuser -u riju -g riju "$@"

54
langs/python.yaml Normal file
View File

@ -0,0 +1,54 @@
id: python
aliases:
- py
- python2
- python3
name: Python
monacoLang: python
install:
apt:
- python3
- python3-pip
pip:
- black
manual:
- |
xml="$(curl -sSL "https://pvsc.blob.core.windows.net/python-language-server-stable?restype=container&comp=list&prefix=Python-Language-Server-linux-x64")"
nupkg="$(echo "$xml" | grep -Eo 'https://[^<]+\.nupkg' | tail -n1)"
wget "${nupkg}"
unzip -d /opt/mspyls Python-Language-Server-linux-x64.*.nupkg
chmod +x /opt/mspyls/Microsoft.Python.LanguageServer
ln -s /opt/mspyls/Microsoft.Python.LanguageServer /usr/local/bin/Microsoft.Python.LanguageServer
repl: >-
python3 -u
main: "main.py"
template: |
print("Hello, world!")
run: "python3 -u -i main.py"
scope:
code: |
x = 123 * 234
format:
run: >-
black -
input: |
print('Hello, world!')
pkg:
install: "pip3 install --user NAME"
uninstall: "pip3 uninstall NAME"
search: >-
python3 -c 'import json; from xmlrpc import client; print(json.dumps(client.ServerProxy("https://pypi.org/pypi").search({"name": "NAME"})))' | jq -r 'map(.name) | .[]'
lsp:
start: "Microsoft.Python.LanguageServer"
init:
interpreter:
properties:
InterpreterPath: "/usr/bin/python3"
code: |
import func
item: "functools"

9
package.json Normal file
View File

@ -0,0 +1,9 @@
{
"name": "riju",
"version": "0.0.0",
"license": "MIT",
"private": true,
"dependencies": {
"yaml": "^1.10.0"
}
}

8
yarn.lock Normal file
View File

@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
yaml@^1.10.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==