Compare commits
4 Commits
hydrators-
...
034b035a91
| Author | SHA1 | Date | |
|---|---|---|---|
| 034b035a91 | |||
| f352ae44e1 | |||
| 341db4f821 | |||
| eabec3816b |
66
backend/check-deps.ts
Normal file
66
backend/check-deps.ts
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { dirname, join } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
|
interface PackageJson {
|
||||||
|
dependencies?: Record<string, string>;
|
||||||
|
devDependencies?: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readPackageJson(path: string): PackageJson {
|
||||||
|
const content = readFileSync(path, "utf-8");
|
||||||
|
return JSON.parse(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAllDependencyNames(pkg: PackageJson): Set<string> {
|
||||||
|
const names = new Set<string>();
|
||||||
|
for (const name of Object.keys(pkg.dependencies ?? {})) {
|
||||||
|
names.add(name);
|
||||||
|
}
|
||||||
|
for (const name of Object.keys(pkg.devDependencies ?? {})) {
|
||||||
|
names.add(name);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
const diachronPkgPath = join(__dirname, "diachron", "package.json");
|
||||||
|
const backendPkgPath = join(__dirname, "package.json");
|
||||||
|
|
||||||
|
const diachronPkg = readPackageJson(diachronPkgPath);
|
||||||
|
const backendPkg = readPackageJson(backendPkgPath);
|
||||||
|
|
||||||
|
const diachronDeps = getAllDependencyNames(diachronPkg);
|
||||||
|
const backendDeps = getAllDependencyNames(backendPkg);
|
||||||
|
|
||||||
|
const duplicates: string[] = [];
|
||||||
|
|
||||||
|
for (const dep of diachronDeps) {
|
||||||
|
if (backendDeps.has(dep)) {
|
||||||
|
duplicates.push(dep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (duplicates.length > 0) {
|
||||||
|
console.error("Error: Duplicate dependencies found.");
|
||||||
|
console.error("");
|
||||||
|
console.error(
|
||||||
|
"The following dependencies exist in both backend/package.json and backend/diachron/package.json:",
|
||||||
|
);
|
||||||
|
console.error("");
|
||||||
|
for (const dep of duplicates.sort()) {
|
||||||
|
console.error(` - ${dep}`);
|
||||||
|
}
|
||||||
|
console.error("");
|
||||||
|
console.error(
|
||||||
|
"Dependencies in backend/diachron/package.json are provided by the framework",
|
||||||
|
);
|
||||||
|
console.error(
|
||||||
|
"and must not be duplicated in backend/package.json. Remove them from",
|
||||||
|
);
|
||||||
|
console.error("backend/package.json to fix this error.");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("No duplicate dependencies found.");
|
||||||
@@ -11,4 +11,5 @@ out_dir="$check_dir/out"
|
|||||||
source "$check_dir"/../diachron/shims/common
|
source "$check_dir"/../diachron/shims/common
|
||||||
source "$check_dir"/../diachron/shims/node.common
|
source "$check_dir"/../diachron/shims/node.common
|
||||||
|
|
||||||
|
$ROOT/cmd tsx "$check_dir/check-deps.ts"
|
||||||
$ROOT/cmd pnpm tsc --outDir "$out_dir"
|
$ROOT/cmd pnpm tsc --outDir "$out_dir"
|
||||||
|
|||||||
39
backend/diachron/package.json
Normal file
39
backend/diachron/package.json
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"name": "express",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "DB_PORT=5433 DB_USER=diachron_test DB_PASSWORD=diachron_test DB_NAME=diachron_test tsx --test '**/*.{test,spec}.ts'",
|
||||||
|
"test:watch": "DB_PORT=5433 DB_USER=diachron_test DB_PASSWORD=diachron_test DB_NAME=diachron_test tsx --test --watch '**/*.{test,spec}.ts'",
|
||||||
|
"nodemon": "nodemon dist/index.js",
|
||||||
|
"kysely-codegen": "kysely-codegen"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"packageManager": "pnpm@10.12.4",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "^24.10.1",
|
||||||
|
"@types/nunjucks": "^3.2.6",
|
||||||
|
"@vercel/ncc": "^0.38.4",
|
||||||
|
"express": "^5.1.0",
|
||||||
|
"kysely": "^0.28.9",
|
||||||
|
"nodemon": "^3.1.11",
|
||||||
|
"nunjucks": "^3.2.4",
|
||||||
|
"path-to-regexp": "^8.3.0",
|
||||||
|
"pg": "^8.16.3",
|
||||||
|
"ts-luxon": "^6.2.0",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
|
"tsx": "^4.20.6",
|
||||||
|
"typeid-js": "^1.2.0",
|
||||||
|
"typescript": "^5.9.3",
|
||||||
|
"zod": "^4.1.12"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@biomejs/biome": "2.3.10",
|
||||||
|
"@types/express": "^5.0.5",
|
||||||
|
"@types/pg": "^8.16.0",
|
||||||
|
"kysely-codegen": "^0.19.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "express",
|
"name": "my app",
|
||||||
"version": "1.0.0",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -14,26 +14,7 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"packageManager": "pnpm@10.12.4",
|
"packageManager": "pnpm@10.12.4",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^24.10.1",
|
|
||||||
"@types/nunjucks": "^3.2.6",
|
|
||||||
"@vercel/ncc": "^0.38.4",
|
|
||||||
"express": "^5.1.0",
|
|
||||||
"kysely": "^0.28.9",
|
|
||||||
"nodemon": "^3.1.11",
|
|
||||||
"nunjucks": "^3.2.4",
|
|
||||||
"path-to-regexp": "^8.3.0",
|
|
||||||
"pg": "^8.16.3",
|
|
||||||
"ts-luxon": "^6.2.0",
|
|
||||||
"ts-node": "^10.9.2",
|
|
||||||
"tsx": "^4.20.6",
|
|
||||||
"typeid-js": "^1.2.0",
|
|
||||||
"typescript": "^5.9.3",
|
|
||||||
"zod": "^4.1.12"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "2.3.10",
|
|
||||||
"@types/express": "^5.0.5",
|
|
||||||
"@types/pg": "^8.16.0",
|
|
||||||
"kysely-codegen": "^0.19.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
backend/pnpm-workspace.yaml
Normal file
2
backend/pnpm-workspace.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
packages:
|
||||||
|
- 'diachron'
|
||||||
@@ -10,5 +10,5 @@
|
|||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"outDir": "out"
|
"outDir": "out"
|
||||||
},
|
},
|
||||||
"exclude": ["**/*.spec.ts", "**/*.test.ts"]
|
"exclude": ["**/*.spec.ts", "**/*.test.ts", "check-deps.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
11
diachron/common.d/check-deps
Executable file
11
diachron/common.d/check-deps
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
ROOT="$DIR/../.."
|
||||||
|
|
||||||
|
cd "$ROOT/backend"
|
||||||
|
|
||||||
|
"$ROOT/cmd" tsx check-deps.ts "$@"
|
||||||
1
diachron/develop.d/check-deps
Symbolic link
1
diachron/develop.d/check-deps
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../common.d/check-deps
|
||||||
1
diachron/mgmt.d/check-deps
Symbolic link
1
diachron/mgmt.d/check-deps
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../common.d/check-deps
|
||||||
14
file-list
Normal file
14
file-list
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# please keep this file sorted alphabetically
|
||||||
|
|
||||||
|
backend/diachron
|
||||||
|
backend/package.json
|
||||||
|
backend/pnpm-workspace.yaml
|
||||||
|
# express/framework
|
||||||
|
cmd
|
||||||
|
develop
|
||||||
|
diachron
|
||||||
|
logger
|
||||||
|
master
|
||||||
|
mgmt
|
||||||
|
sync.sh
|
||||||
|
templates
|
||||||
66
sync.sh
66
sync.sh
@@ -1,7 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Note: This is kind of AI slop and needs to be more carefully reviewed.
|
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
@@ -25,50 +23,66 @@ pnpm_checksum_var="pnpm_checksum_${platform}"
|
|||||||
pnpm_binary_url="${!pnpm_binary_var}"
|
pnpm_binary_url="${!pnpm_binary_var}"
|
||||||
pnpm_checksum="${!pnpm_checksum_var}"
|
pnpm_checksum="${!pnpm_checksum_var}"
|
||||||
|
|
||||||
# Set up paths for shims to use
|
cache_dir="$HOME/.cache/diachron/v1/binaries"
|
||||||
nodejs_dist_dir="diachron/binaries/$nodejs_dirname"
|
local_dir="$DIR/diachron/binaries"
|
||||||
nodejs_bin_dir="$nodejs_dist_dir/bin"
|
mkdir -p "$cache_dir" "$local_dir"
|
||||||
|
|
||||||
# Ensure correct node version is installed
|
# read_checksum_file <path>
|
||||||
node_installed_checksum_file="$DIR/diachron/binaries/.node.checksum"
|
# Prints the contents of a checksum file, or empty string
|
||||||
node_installed_checksum=""
|
# if the file does not exist.
|
||||||
if [ -f "$node_installed_checksum_file" ]; then
|
read_checksum_file() {
|
||||||
node_installed_checksum=$(cat "$node_installed_checksum_file")
|
if [ -f "$1" ]; then
|
||||||
fi
|
cat "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ "$node_installed_checksum" != "$nodejs_checksum" ]; then
|
# Ensure Node.js is in the cache
|
||||||
|
cached_node_checksum=$(read_checksum_file "$cache_dir/.node.checksum")
|
||||||
|
if [ "$cached_node_checksum" != "$nodejs_checksum" ]; then
|
||||||
echo "Downloading Node.js for $platform..."
|
echo "Downloading Node.js for $platform..."
|
||||||
node_archive="$DIR/diachron/downloads/node.tar.xz"
|
node_archive="$cache_dir/node.tar.xz"
|
||||||
curl -fsSL "$nodejs_binary" -o "$node_archive"
|
curl -fsSL "$nodejs_binary" -o "$node_archive"
|
||||||
|
|
||||||
echo "Verifying checksum..."
|
echo "Verifying checksum..."
|
||||||
echo "$nodejs_checksum $node_archive" | sha256_check
|
echo "$nodejs_checksum $node_archive" | sha256_check
|
||||||
|
|
||||||
echo "Extracting Node.js..."
|
echo "Extracting Node.js..."
|
||||||
tar -xf "$node_archive" -C "$DIR/diachron/binaries"
|
rm -rf "${cache_dir:?}/$nodejs_dirname"
|
||||||
|
tar -xf "$node_archive" -C "$cache_dir"
|
||||||
rm "$node_archive"
|
rm "$node_archive"
|
||||||
|
|
||||||
echo "$nodejs_checksum" >"$node_installed_checksum_file"
|
echo "$nodejs_checksum" >"$cache_dir/.node.checksum"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure correct pnpm version is installed
|
# Copy Node.js into the working directory if needed
|
||||||
pnpm_binary="$DIR/diachron/binaries/pnpm"
|
local_node_checksum=$(read_checksum_file "$local_dir/.node.checksum")
|
||||||
pnpm_installed_checksum_file="$DIR/diachron/binaries/.pnpm.checksum"
|
if [ "$local_node_checksum" != "$nodejs_checksum" ]; then
|
||||||
pnpm_installed_checksum=""
|
echo "Installing Node.js into project..."
|
||||||
if [ -f "$pnpm_installed_checksum_file" ]; then
|
rm -rf "${local_dir:?}/$nodejs_dirname"
|
||||||
pnpm_installed_checksum=$(cat "$pnpm_installed_checksum_file")
|
cp -R "$cache_dir/$nodejs_dirname" "$local_dir/$nodejs_dirname"
|
||||||
|
echo "$nodejs_checksum" >"$local_dir/.node.checksum"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$pnpm_installed_checksum" != "$pnpm_checksum" ]; then
|
# Ensure pnpm is in the cache
|
||||||
|
cached_pnpm_checksum=$(read_checksum_file "$cache_dir/.pnpm.checksum")
|
||||||
|
if [ "$cached_pnpm_checksum" != "$pnpm_checksum" ]; then
|
||||||
echo "Downloading pnpm for $platform..."
|
echo "Downloading pnpm for $platform..."
|
||||||
curl -fsSL "$pnpm_binary_url" -o "$pnpm_binary"
|
curl -fsSL "$pnpm_binary_url" -o "$cache_dir/pnpm"
|
||||||
|
|
||||||
echo "Verifying checksum..."
|
echo "Verifying checksum..."
|
||||||
echo "$pnpm_checksum $pnpm_binary" | sha256_check
|
echo "$pnpm_checksum $cache_dir/pnpm" | sha256_check
|
||||||
|
|
||||||
chmod +x "$pnpm_binary"
|
chmod +x "$cache_dir/pnpm"
|
||||||
|
|
||||||
echo "$pnpm_checksum" >"$pnpm_installed_checksum_file"
|
echo "$pnpm_checksum" >"$cache_dir/.pnpm.checksum"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy pnpm into the working directory if needed
|
||||||
|
local_pnpm_checksum=$(read_checksum_file "$local_dir/.pnpm.checksum")
|
||||||
|
if [ "$local_pnpm_checksum" != "$pnpm_checksum" ]; then
|
||||||
|
echo "Installing pnpm into project..."
|
||||||
|
cp "$cache_dir/pnpm" "$local_dir/pnpm"
|
||||||
|
echo "$pnpm_checksum" >"$local_dir/.pnpm.checksum"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get golang binaries in place
|
# Get golang binaries in place
|
||||||
|
|||||||
38
upgrade.sh
Normal file
38
upgrade.sh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# shellcheck disable=SC2002
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
set -o pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
# print useful message on failure
|
||||||
|
trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
# - Check if the file .diachron-version exists; save its value in a variable
|
||||||
|
# named old_diachron_version
|
||||||
|
|
||||||
|
# - Check if the repository is dirty; if there are any files that git knows
|
||||||
|
# about that have been changed but not committed, abort with a message
|
||||||
|
|
||||||
|
# - Get the current commit and store it in a variable
|
||||||
|
|
||||||
|
# - Perform a two checkouts of
|
||||||
|
# https://gitea.philologue.net/philologue/diachron, each in its own
|
||||||
|
# temporary directory. We'll call one "old" and one "new"
|
||||||
|
|
||||||
|
# - In old, check out $old_diachron_version; in our working application
|
||||||
|
# directory, delete all of the files in file-list using git rm
|
||||||
|
|
||||||
|
# - In new, check out whatever was passed as argv[1]
|
||||||
|
|
||||||
|
# - Copy all of the files in file-list to the working application and stage
|
||||||
|
# them with git add
|
||||||
|
|
||||||
|
# - Commit
|
||||||
|
|
||||||
|
# - Should we run sync.sh or should we advise the user to run sync.sh?
|
||||||
Reference in New Issue
Block a user