Compare commits
9 Commits
940cef138e
...
hydrators-
| Author | SHA1 | Date | |
|---|---|---|---|
| 09d85c8f22 | |||
| a0ce5183b2 | |||
| c83202b681 | |||
| 2c1d297be1 | |||
| 2d697c1e61 | |||
| 410bb671f1 | |||
| 0ae197f939 | |||
| 370bea5d98 | |||
| 9d34768051 |
@@ -1,66 +0,0 @@
|
|||||||
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,5 +11,4 @@ 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"
|
||||||
|
|||||||
@@ -10,5 +10,5 @@
|
|||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"outDir": "out"
|
"outDir": "out"
|
||||||
},
|
},
|
||||||
"exclude": ["**/*.spec.ts", "**/*.test.ts", "check-deps.ts"]
|
"exclude": ["**/*.spec.ts", "**/*.test.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
49
bootstrap.sh
49
bootstrap.sh
@@ -1,49 +0,0 @@
|
|||||||
#!/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"
|
|
||||||
here="$PWD"
|
|
||||||
|
|
||||||
"$DIR/update-cached-repository.sh"
|
|
||||||
|
|
||||||
# repository="${2:-https://gitea.philologue.net/philologue/diachron}"
|
|
||||||
repository="${2:-$HOME/.cache/diachron/v1/repositories/diachron.git}"
|
|
||||||
ref="${1:-hydrators-kysely}"
|
|
||||||
|
|
||||||
echo will bootstrap ref "$ref" of repo "$repository"
|
|
||||||
|
|
||||||
into=$(mktemp -d)
|
|
||||||
cd "$into"
|
|
||||||
echo I am in $(pwd)
|
|
||||||
echo I will clone repository "$repository", ref "$ref"
|
|
||||||
git clone "$repository"
|
|
||||||
|
|
||||||
r=$(ls -1)
|
|
||||||
|
|
||||||
cd "$r"
|
|
||||||
|
|
||||||
echo I am in $(pwd)
|
|
||||||
|
|
||||||
git checkout "$ref"
|
|
||||||
|
|
||||||
ls
|
|
||||||
echo working dir: $PWD
|
|
||||||
# ls backend
|
|
||||||
|
|
||||||
# exit 0
|
|
||||||
|
|
||||||
tar cvf - $(cat "$PWD/file-list" | grep -v '^#') | (cd "$here" && tar xf -)
|
|
||||||
|
|
||||||
echo "$ref" > .diachron-version
|
|
||||||
|
|
||||||
echo "Now, run the command ./sync.sh"
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
|
|
||||||
ROOT="$DIR/../.."
|
|
||||||
|
|
||||||
cd "$ROOT/backend"
|
|
||||||
|
|
||||||
"$ROOT/cmd" tsx check-deps.ts "$@"
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../common.d/check-deps
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../common.d/check-deps
|
|
||||||
@@ -5,7 +5,6 @@ backend/package.json
|
|||||||
backend/pnpm-workspace.yaml
|
backend/pnpm-workspace.yaml
|
||||||
# express/framework
|
# express/framework
|
||||||
cmd
|
cmd
|
||||||
file-list
|
|
||||||
develop
|
develop
|
||||||
diachron
|
diachron
|
||||||
logger
|
logger
|
||||||
@@ -13,4 +12,3 @@ master
|
|||||||
mgmt
|
mgmt
|
||||||
sync.sh
|
sync.sh
|
||||||
templates
|
templates
|
||||||
upgrade.sh
|
|
||||||
|
|||||||
66
sync.sh
66
sync.sh
@@ -1,5 +1,7 @@
|
|||||||
#!/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)"
|
||||||
@@ -23,66 +25,50 @@ 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}"
|
||||||
|
|
||||||
cache_dir="$HOME/.cache/diachron/v1/binaries"
|
# Set up paths for shims to use
|
||||||
local_dir="$DIR/diachron/binaries"
|
nodejs_dist_dir="diachron/binaries/$nodejs_dirname"
|
||||||
mkdir -p "$cache_dir" "$local_dir"
|
nodejs_bin_dir="$nodejs_dist_dir/bin"
|
||||||
|
|
||||||
# read_checksum_file <path>
|
# Ensure correct node version is installed
|
||||||
# Prints the contents of a checksum file, or empty string
|
node_installed_checksum_file="$DIR/diachron/binaries/.node.checksum"
|
||||||
# if the file does not exist.
|
node_installed_checksum=""
|
||||||
read_checksum_file() {
|
if [ -f "$node_installed_checksum_file" ]; then
|
||||||
if [ -f "$1" ]; then
|
node_installed_checksum=$(cat "$node_installed_checksum_file")
|
||||||
cat "$1"
|
fi
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ensure Node.js is in the cache
|
if [ "$node_installed_checksum" != "$nodejs_checksum" ]; then
|
||||||
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="$cache_dir/node.tar.xz"
|
node_archive="$DIR/diachron/downloads/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..."
|
||||||
rm -rf "${cache_dir:?}/$nodejs_dirname"
|
tar -xf "$node_archive" -C "$DIR/diachron/binaries"
|
||||||
tar -xf "$node_archive" -C "$cache_dir"
|
|
||||||
rm "$node_archive"
|
rm "$node_archive"
|
||||||
|
|
||||||
echo "$nodejs_checksum" >"$cache_dir/.node.checksum"
|
echo "$nodejs_checksum" >"$node_installed_checksum_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy Node.js into the working directory if needed
|
# Ensure correct pnpm version is installed
|
||||||
local_node_checksum=$(read_checksum_file "$local_dir/.node.checksum")
|
pnpm_binary="$DIR/diachron/binaries/pnpm"
|
||||||
if [ "$local_node_checksum" != "$nodejs_checksum" ]; then
|
pnpm_installed_checksum_file="$DIR/diachron/binaries/.pnpm.checksum"
|
||||||
echo "Installing Node.js into project..."
|
pnpm_installed_checksum=""
|
||||||
rm -rf "${local_dir:?}/$nodejs_dirname"
|
if [ -f "$pnpm_installed_checksum_file" ]; then
|
||||||
cp -R "$cache_dir/$nodejs_dirname" "$local_dir/$nodejs_dirname"
|
pnpm_installed_checksum=$(cat "$pnpm_installed_checksum_file")
|
||||||
echo "$nodejs_checksum" >"$local_dir/.node.checksum"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure pnpm is in the cache
|
if [ "$pnpm_installed_checksum" != "$pnpm_checksum" ]; then
|
||||||
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 "$cache_dir/pnpm"
|
curl -fsSL "$pnpm_binary_url" -o "$pnpm_binary"
|
||||||
|
|
||||||
echo "Verifying checksum..."
|
echo "Verifying checksum..."
|
||||||
echo "$pnpm_checksum $cache_dir/pnpm" | sha256_check
|
echo "$pnpm_checksum $pnpm_binary" | sha256_check
|
||||||
|
|
||||||
chmod +x "$cache_dir/pnpm"
|
chmod +x "$pnpm_binary"
|
||||||
|
|
||||||
echo "$pnpm_checksum" >"$cache_dir/.pnpm.checksum"
|
echo "$pnpm_checksum" >"$pnpm_installed_checksum_file"
|
||||||
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
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -eu
|
|
||||||
set -o pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
|
|
||||||
|
|
||||||
upstream=https://gitea.philologue.net/philologue/diachron
|
|
||||||
cache_dir="$HOME/.cache/diachron/v1/repositories"
|
|
||||||
cached_repo="$cache_dir/diachron.git"
|
|
||||||
|
|
||||||
mkdir -p "$cache_dir"
|
|
||||||
|
|
||||||
if [ -d "$cached_repo" ]; then
|
|
||||||
echo "Updating cached repository..."
|
|
||||||
git -C "$cached_repo" fetch --prune origin
|
|
||||||
else
|
|
||||||
echo "Creating cached repository..."
|
|
||||||
git clone --mirror "$upstream" "$cached_repo"
|
|
||||||
fi
|
|
||||||
|
|
||||||
109
upgrade.sh
109
upgrade.sh
@@ -1,109 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -eu
|
|
||||||
set -o pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
|
|
||||||
new_ref="${1:?Usage: upgrade.sh <new-ref>}"
|
|
||||||
|
|
||||||
cached_repo="$HOME/.cache/diachron/v1/repositories/diachron.git"
|
|
||||||
tmpdir=""
|
|
||||||
|
|
||||||
cleanup() {
|
|
||||||
if [ -n "$tmpdir" ]; then
|
|
||||||
rm -rf "$tmpdir"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
echo "=== Diachron Framework Upgrade ==="
|
|
||||||
echo ""
|
|
||||||
echo "This will replace all framework files in your project."
|
|
||||||
echo "Make sure you have committed or backed up any local changes."
|
|
||||||
echo ""
|
|
||||||
read -r -p "Continue? [y/N] " answer
|
|
||||||
if [[ ! "$answer" =~ ^[Yy]$ ]]; then
|
|
||||||
echo "Aborted."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update cached repository
|
|
||||||
"$DIR/update-cached-repository.sh"
|
|
||||||
|
|
||||||
# Read current version
|
|
||||||
if [ ! -f "$DIR/.diachron-version" ]; then
|
|
||||||
echo "Error: .diachron-version not found." >&2
|
|
||||||
echo "Is this a diachron project?" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
old_ref=$(cat "$DIR/.diachron-version")
|
|
||||||
|
|
||||||
# Verify both refs exist in cached repo
|
|
||||||
if ! git -C "$cached_repo" rev-parse --verify "$old_ref^{commit}" >/dev/null 2>&1; then
|
|
||||||
echo "Error: current version '$old_ref' not found in cached repository." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if ! git -C "$cached_repo" rev-parse --verify "$new_ref^{commit}" >/dev/null 2>&1; then
|
|
||||||
echo "Error: target version '$new_ref' not found in cached repository." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Require a clean working tree
|
|
||||||
if [ -n "$(git -C "$DIR" status --porcelain)" ]; then
|
|
||||||
echo "Error: working tree is not clean." >&2
|
|
||||||
echo "Commit or stash all changes (including untracked files) before upgrading." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "Upgrading: $old_ref -> $new_ref"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Read current file-list (files to remove)
|
|
||||||
old_files=()
|
|
||||||
while IFS= read -r line; do
|
|
||||||
[[ "$line" =~ ^[[:space:]]*# ]] && continue
|
|
||||||
[[ -z "$line" ]] && continue
|
|
||||||
old_files+=("$line")
|
|
||||||
done < "$DIR/file-list"
|
|
||||||
|
|
||||||
# Clone and checkout new version into a temp directory
|
|
||||||
tmpdir=$(mktemp -d)
|
|
||||||
git clone --quiet "$cached_repo" "$tmpdir/diachron"
|
|
||||||
git -C "$tmpdir/diachron" checkout --quiet "$new_ref"
|
|
||||||
|
|
||||||
# Read new file-list (files to add)
|
|
||||||
new_files=()
|
|
||||||
while IFS= read -r line; do
|
|
||||||
[[ "$line" =~ ^[[:space:]]*# ]] && continue
|
|
||||||
[[ -z "$line" ]] && continue
|
|
||||||
new_files+=("$line")
|
|
||||||
done < "$tmpdir/diachron/file-list"
|
|
||||||
|
|
||||||
# Remove old framework files
|
|
||||||
for f in "${old_files[@]}"; do
|
|
||||||
git -C "$DIR" rm -rf --quiet --ignore-unmatch "$f"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Copy in new framework files
|
|
||||||
(cd "$tmpdir/diachron" && tar cvf - "${new_files[@]}") | (cd "$DIR" && tar xf -)
|
|
||||||
|
|
||||||
# Stage them
|
|
||||||
for f in "${new_files[@]}"; do
|
|
||||||
git -C "$DIR" add "$f"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Update version marker
|
|
||||||
echo "$new_ref" > "$DIR/.diachron-version"
|
|
||||||
git -C "$DIR" add "$DIR/.diachron-version"
|
|
||||||
|
|
||||||
echo "=== Upgrade staged: $old_ref -> $new_ref ==="
|
|
||||||
echo ""
|
|
||||||
echo "Framework files have been removed, replaced, and staged."
|
|
||||||
echo ""
|
|
||||||
echo "Next steps:"
|
|
||||||
echo " 1. Review: git diff --cached"
|
|
||||||
echo " 2. Commit: git commit -m 'Upgrade diachron to $new_ref'"
|
|
||||||
echo " 3. Install: ./sync.sh"
|
|
||||||
Reference in New Issue
Block a user