···11+# how to setup local appview dev environment
22+33+Appview requires several microservices from knot and spindle to entire atproto infra. This test environment is implemented under nixos vm.
44+55+1. copy `contrib/example.env` to `.env`, fill it and source it
66+2. run vm
77+ ```bash
88+ nix run --impure .#vm
99+ ```
1010+3. trust the generated cert from host machine
1111+ ```bash
1212+ # for macos
1313+ sudo security add-trusted-cert -d -r trustRoot \
1414+ -k /Library/Keychains/System.keychain \
1515+ ./nix/vm-data/caddy/.local/share/caddy/pki/authorities/local/root.crt
1616+ ```
1717+4. create test accounts with valid emails (use [`create-test-account.sh`](./scripts/create-test-account.sh))
1818+5. create default labels (use [`setup-const-records`](./scripts/setup-const-records.sh))
1919+6. restart vm with correct owner-did
2020+2121+for git-https, you should change your local git config:
2222+```
2323+[http "https://knot.tngl.boltless.dev"]
2424+ sslCAPath = /Users/boltless/repo/tangled/nix/vm-data/caddy/.local/share/caddy/pki/authorities/local/
2525+```
+68
contrib/scripts/create-test-account.sh
···11+#!/bin/bash
22+set -o errexit
33+set -o nounset
44+set -o pipefail
55+66+source "$(dirname "$0")/../pds.env"
77+88+# PDS_HOSTNAME=
99+# PDS_ADMIN_PASSWORD=
1010+1111+# curl a URL and fail if the request fails.
1212+function curl_cmd_get {
1313+ curl --fail --silent --show-error "$@"
1414+}
1515+1616+# curl a URL and fail if the request fails.
1717+function curl_cmd_post {
1818+ curl --fail --silent --show-error --request POST --header "Content-Type: application/json" "$@"
1919+}
2020+2121+# curl a URL but do not fail if the request fails.
2222+function curl_cmd_post_nofail {
2323+ curl --silent --show-error --request POST --header "Content-Type: application/json" "$@"
2424+}
2525+2626+USERNAME="${1:-}"
2727+2828+if [[ "${USERNAME}" == "" ]]; then
2929+ read -p "Enter a username: " USERNAME
3030+fi
3131+3232+if [[ "${USERNAME}" == "" ]]; then
3333+ echo "ERROR: missing USERNAME parameter." >/dev/stderr
3434+ echo "Usage: $0 ${SUBCOMMAND} <USERNAME>" >/dev/stderr
3535+ exit 1
3636+fi
3737+3838+EMAIL=${USERNAME}@${PDS_HOSTNAME}
3939+4040+PASSWORD="password"
4141+INVITE_CODE="$(curl_cmd_post \
4242+ --user "admin:${PDS_ADMIN_PASSWORD}" \
4343+ --data '{"useCount": 1}' \
4444+ "https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createInviteCode" | jq --raw-output '.code'
4545+)"
4646+RESULT="$(curl_cmd_post_nofail \
4747+ --data "{\"email\":\"${EMAIL}\", \"handle\":\"${USERNAME}.${PDS_HOSTNAME}\", \"password\":\"${PASSWORD}\", \"inviteCode\":\"${INVITE_CODE}\"}" \
4848+ "https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createAccount"
4949+)"
5050+5151+DID="$(echo $RESULT | jq --raw-output '.did')"
5252+if [[ "${DID}" != did:* ]]; then
5353+ ERR="$(echo ${RESULT} | jq --raw-output '.message')"
5454+ echo "ERROR: ${ERR}" >/dev/stderr
5555+ echo "Usage: $0 <EMAIL> <HANDLE>" >/dev/stderr
5656+ exit 1
5757+fi
5858+5959+echo
6060+echo "Account created successfully!"
6161+echo "-----------------------------"
6262+echo "Handle : ${USERNAME}.${PDS_HOSTNAME}"
6363+echo "DID : ${DID}"
6464+echo "Password : ${PASSWORD}"
6565+echo "-----------------------------"
6666+echo "This is a test account with an insecure password."
6767+echo "Make sure it's only used for development."
6868+echo