iterate.com / config-template

git clone https://git.iterate.com/repos/config-template

config-template / clone.shmain at 3b8ad1b

#!/bin/sh
# clone.sh — the repos this config needs, cloned beside it and installed, so that a laptop holds
# them side by side as the mind does.
#
#   git clone https://git.<domain>/repos/config <folder>/config
#   <folder>/config/clone.sh
#
# Which repos: each one that package.json names as the folder next door
# ("@repos/stdlib": "../stdlib"), the kernel, whose SDK every repo is type-checked against, and
# any more that are named after the command (`clone.sh task-board`). Where from: beside the
# address this repo was cloned from. A mind is born the same way, from the same list.
#
# Then it installs: the kernel's own packages, and in each other repo its tools and the links to
# its neighbours. A repo that is here already is left as it is, and installed again.
set -eu
cd "$(dirname "$0")"

origin=$(git remote get-url origin)
base="${origin%/*}"
named=$(node -p 'Object.keys(require("./package.json").dependencies).filter((name) => name.startsWith("@repos/")).map((name) => name.slice("@repos/".length)).join(" ")')

for name in kernel $named "$@"; do
  if [ -d "../$name/.git" ]; then
    echo "$name: here already"
  else
    git clone "$base/$name" "../$name"
  fi
done

pnpm -C ../kernel install
for name in $named; do pnpm -C "../$name" install; done
pnpm install