Load language configurations into server
This commit is contained in:
parent
feb5aad8f0
commit
83208355d4
|
@ -5,5 +5,6 @@
|
||||||
**/.lsp-repl-history
|
**/.lsp-repl-history
|
||||||
**/.terraform
|
**/.terraform
|
||||||
**/build
|
**/build
|
||||||
|
**/build-docker
|
||||||
**/node_modules
|
**/node_modules
|
||||||
**/out
|
**/out
|
||||||
|
|
|
@ -4,5 +4,8 @@
|
||||||
.lsp-repl-history
|
.lsp-repl-history
|
||||||
.terraform
|
.terraform
|
||||||
build
|
build
|
||||||
|
# Separate directory for things that are ignored by Git but not by
|
||||||
|
# Docker.
|
||||||
|
build-docker
|
||||||
node_modules
|
node_modules
|
||||||
out
|
out
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -256,11 +256,11 @@ publish: # Full synchronization and prod deployment
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
|
||||||
## Run this every time you update .gitignore.
|
## Run this every time you update .gitignore or .dockerignore.in.
|
||||||
|
|
||||||
dockerignore: # Update .dockerignore from .gitignore
|
dockerignore: # Update .dockerignore from .gitignore and .dockerignore.in
|
||||||
echo "# This file is generated by 'make dockerignore', do not edit." > .dockerignore
|
echo "# This file is generated by 'make dockerignore', do not edit." > .dockerignore
|
||||||
cat .gitignore | sed 's#^#**/#' >> .dockerignore
|
cat .gitignore | sed 's/#.*//' | grep . | sed 's#^#**/#' >> .dockerignore
|
||||||
|
|
||||||
## You need to be inside a 'make env' shell whenever you are running
|
## You need to be inside a 'make env' shell whenever you are running
|
||||||
## manual commands (Docker, Terraform, Packer, etc.) directly, as
|
## manual commands (Docker, Terraform, Packer, etc.) directly, as
|
||||||
|
|
|
@ -3,6 +3,7 @@ import path from "path";
|
||||||
|
|
||||||
import debounce from "debounce";
|
import debounce from "debounce";
|
||||||
|
|
||||||
|
import { getLangs, readLangConfig } from "../lib/yaml.js";
|
||||||
import { log } from "./util.js";
|
import { log } from "./util.js";
|
||||||
|
|
||||||
// Map from language IDs to language configuration objects. This is
|
// Map from language IDs to language configuration objects. This is
|
||||||
|
@ -16,24 +17,14 @@ export let aliases = {};
|
||||||
// global langs variable in this module. Never throw an error. If
|
// global langs variable in this module. Never throw an error. If
|
||||||
// there is a problem then just leave the languages as they previously
|
// there is a problem then just leave the languages as they previously
|
||||||
// were.
|
// were.
|
||||||
async function readLangsFromDisk() {
|
async function updateLangsFromDisk() {
|
||||||
try {
|
try {
|
||||||
const newLangs = {};
|
const newLangs = {};
|
||||||
const newAliases = {};
|
const newAliases = {};
|
||||||
for (const filename of await fs.readdir("/opt/riju/langs")) {
|
for (const langConfig of await Promise.all(
|
||||||
if (path.parse(filename).ext !== ".json") {
|
(await getLangs()).map(readLangConfig)
|
||||||
continue;
|
)) {
|
||||||
}
|
const { id } = langConfig;
|
||||||
const id = path.parse(filename).name;
|
|
||||||
const langConfig = JSON.parse(
|
|
||||||
await fs.readFile(`/opt/riju/langs/${filename}`, "utf-8")
|
|
||||||
);
|
|
||||||
if (langConfig.id !== id) {
|
|
||||||
log.error(
|
|
||||||
"Language config ${filename} has mismatched language ID ${id}, ignoring"
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
newLangs[id] = langConfig;
|
newLangs[id] = langConfig;
|
||||||
newAliases[id] = id;
|
newAliases[id] = id;
|
||||||
for (const alias of langConfig.aliases || []) {
|
for (const alias of langConfig.aliases || []) {
|
||||||
|
@ -52,6 +43,6 @@ async function readLangsFromDisk() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const langsPromise = readLangsFromDisk().then(() => langs);
|
export const langsPromise = updateLangsFromDisk().then(() => langs);
|
||||||
|
|
||||||
fsOrig.watch("/opt/riju/langs", debounce(readLangsFromDisk, 200));
|
fsOrig.watch("langs", debounce(updateLangsFromDisk, 200));
|
||||||
|
|
|
@ -18,7 +18,9 @@ RUN make frontend
|
||||||
|
|
||||||
COPY frontend/pages ./frontend/pages/
|
COPY frontend/pages ./frontend/pages/
|
||||||
COPY frontend/styles ./frontend/styles/
|
COPY frontend/styles ./frontend/styles/
|
||||||
|
COPY lib ./lib/
|
||||||
COPY backend ./backend/
|
COPY backend ./backend/
|
||||||
|
COPY langs ./langs/
|
||||||
|
|
||||||
FROM ubuntu:rolling
|
FROM ubuntu:rolling
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import http from "http";
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
|
|
||||||
import { readLangConfig } from "./config.js";
|
import { readLangConfig } from "../lib/yaml.js";
|
||||||
import { getLocalImageLabel } from "./docker-util.js";
|
import { getLocalImageLabel } from "./docker-util.js";
|
||||||
import { hashDockerfile } from "./hash-dockerfile.js";
|
import { hashDockerfile } from "./hash-dockerfile.js";
|
||||||
import { getDebHash, runCommand } from "./util.js";
|
import { getDebHash, runCommand } from "./util.js";
|
||||||
|
@ -67,7 +67,9 @@ async function main() {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch((err) => {
|
if (process.argv[1] === url.fileURLToPath(import.meta.url)) {
|
||||||
console.error(err);
|
main().catch((err) => {
|
||||||
process.exit(1);
|
console.error(err);
|
||||||
});
|
process.exit(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import url from "url";
|
||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import YAML from "yaml";
|
import YAML from "yaml";
|
||||||
|
|
||||||
import { readLangConfig, readSharedDepConfig } from "./config.js";
|
import { readLangConfig, readSharedDepConfig } from "../lib/yaml.js";
|
||||||
|
|
||||||
// Given a language config object, return the text of a Bash script
|
// Given a language config object, return the text of a Bash script
|
||||||
// that will build the (unpacked) riju-lang-foo Debian package into
|
// that will build the (unpacked) riju-lang-foo Debian package into
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import process from "process";
|
import process from "process";
|
||||||
import url from "url";
|
import url from "url";
|
||||||
|
|
||||||
import { getPackages } from "./config.js";
|
import { getPackages } from "../lib/yaml.js";
|
||||||
import { runCommand } from "./util.js";
|
import { runCommand } from "./util.js";
|
||||||
|
|
||||||
// Parse command-line arguments, run main functionality, and exit.
|
// Parse command-line arguments, run main functionality, and exit.
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { Command } from "commander";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { v4 as getUUID } from "uuid";
|
import { v4 as getUUID } from "uuid";
|
||||||
|
|
||||||
import { getLangs, getPackages, readLangConfig } from "./config.js";
|
import { getLangs, getPackages, readLangConfig } from "../lib/yaml.js";
|
||||||
import {
|
import {
|
||||||
getLocalImageDigest,
|
getLocalImageDigest,
|
||||||
getLocalImageLabel,
|
getLocalImageLabel,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import nodePath from "path";
|
||||||
import process from "process";
|
import process from "process";
|
||||||
import url from "url";
|
import url from "url";
|
||||||
|
|
||||||
import { getPackages } from "./config.js";
|
import { getPackages } from "../lib/yaml.js";
|
||||||
import { generateBuildScript } from "./generate-build-script.js";
|
import { generateBuildScript } from "./generate-build-script.js";
|
||||||
|
|
||||||
// Parse command-line arguments, run main functionality, and exit.
|
// Parse command-line arguments, run main functionality, and exit.
|
||||||
|
|
Loading…
Reference in New Issue