2023-09-24 13:16:22 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
version=
|
|
|
|
gitArgs=
|
|
|
|
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
|
|
i="$1"
|
|
|
|
shift 1
|
|
|
|
case "$i" in
|
2023-11-20 17:24:12 +01:00
|
|
|
--version | -v)
|
2023-09-24 13:16:22 +02:00
|
|
|
version="$1"
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
--git-args)
|
2023-11-20 17:24:12 +01:00
|
|
|
gitArgs="$gitArgs $1"
|
|
|
|
shift 1
|
|
|
|
;;
|
2023-09-24 13:16:22 +02:00
|
|
|
*)
|
|
|
|
echo "$0: unknown option \`$i'"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# Create a working environment
|
|
|
|
CWD=$(pwd)
|
|
|
|
|
|
|
|
TMP=$(mktemp -d)
|
2024-04-17 14:47:51 +02:00
|
|
|
cd "$TMP" || exit 1
|
2023-09-24 13:16:22 +02:00
|
|
|
|
|
|
|
# Fetch the latest source or the required version
|
|
|
|
gitUrl="https://github.com/demarches-simplifiees/demarches-simplifiees.fr.git"
|
|
|
|
|
|
|
|
if [ -n "$version" ]; then
|
2024-04-17 14:47:51 +02:00
|
|
|
git clone --depth 1 --branch "$version" $gitUrl .
|
2023-09-24 13:16:22 +02:00
|
|
|
else
|
|
|
|
git clone --depth 1 $gitUrl .
|
2023-11-10 11:18:34 +01:00
|
|
|
|
2023-11-20 17:24:12 +01:00
|
|
|
version="$(git rev-parse HEAD)"
|
2023-09-24 13:16:22 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Generate gemset.nix
|
2023-11-20 17:24:12 +01:00
|
|
|
nix-shell -p bundix --run "bundix -l" >/dev/null
|
2023-09-24 13:16:22 +02:00
|
|
|
|
|
|
|
# Copy the new files
|
|
|
|
cp gemset.nix Gemfile Gemfile.lock "$CWD/rubyEnv/"
|
|
|
|
|
|
|
|
# Print the new source details
|
2023-11-16 09:21:34 +01:00
|
|
|
SRC_HASH=$(nix-shell -p nurl --run "nurl --hash $gitUrl $version")
|
2023-11-10 11:18:34 +01:00
|
|
|
|
2024-04-17 14:47:51 +02:00
|
|
|
# Switch to bun
|
|
|
|
nix-shell -p bun --run "bun install --frozen-lockfile --no-cache --no-progress --ignore-scripts"
|
2023-11-10 11:18:34 +01:00
|
|
|
|
2024-04-17 14:47:51 +02:00
|
|
|
DEPS_HASH=$(nix-hash --sri --type sha256 node_modules)
|
2023-11-16 09:21:34 +01:00
|
|
|
|
2023-11-20 17:24:12 +01:00
|
|
|
cat <<EOF >"$CWD/meta.nix"
|
2023-11-16 09:21:34 +01:00
|
|
|
{
|
2024-02-06 13:00:57 +01:00
|
|
|
version = "$version";
|
|
|
|
src-hash = "$SRC_HASH";
|
|
|
|
deps-hash = "$DEPS_HASH";
|
2023-11-16 09:21:34 +01:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2024-04-17 14:47:51 +02:00
|
|
|
nix-shell -p nixfmt-rfc-style --run "nixfmt $CWD"
|
2024-02-07 18:47:45 +01:00
|
|
|
|
2023-11-16 09:21:34 +01:00
|
|
|
rm -rf "$TMP"
|