From 0dabb08217b4390c25aaa728a589d1855f0a8211 Mon Sep 17 00:00:00 2001 From: EYHN Date: Tue, 27 Feb 2024 03:32:03 +0000 Subject: [PATCH] chore: create default user for devcontainer (#5917) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Type** enhancement ___ ## **Description** - Added a command to `.devcontainer/build.sh` to create a default user (`affine`) in the database for development purposes. - Introduced error handling in `.devcontainer/setup-user.sh` to ensure the script stops on the first error. - Modified the git fetch command in `.devcontainer/setup-user.sh` to fetch the `canary` branch from `origin` with a depth of 1, optimizing the setup process. ___ ## **Changes walkthrough**
Relevant files
Enhancement
build.sh
Add Default User Creation to Dev Container Build Script   

.devcontainer/build.sh
  • Added command to create a default user with username and password
    'affine'.
  • Ensured database push command is followed by a newline.
  • +4/-1     
    setup-user.sh
    Enhance User Setup Script with Error Handling and Specific Git Fetch

    .devcontainer/setup-user.sh
  • Introduced error handling with 'set -e' to stop on first error.
  • Modified 'git fetch' to specifically fetch 'canary' branch from
    'origin' with depth of 1.
  • +3/-1     
    ___ > ✨ **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions --- .devcontainer/build.sh | 5 ++++- .devcontainer/setup-user.sh | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh index aae6965bf..5095dd3ce 100644 --- a/.devcontainer/build.sh +++ b/.devcontainer/build.sh @@ -12,4 +12,7 @@ yarn install yarn workspace @affine/storage build # Create database -yarn workspace @affine/server prisma db push \ No newline at end of file +yarn workspace @affine/server prisma db push + +# Create user username: affine, password: affine +echo "INSERT INTO \"users\"(\"id\",\"name\",\"email\",\"email_verified\",\"created_at\",\"password\") VALUES('99f3ad04-7c9b-441e-a6db-79f73aa64db9','affine','affine@affine.pro','2024-02-26 15:54:16.974','2024-02-26 15:54:16.974+00','\$argon2id\$v=19\$m=19456,t=2,p=1\$esDS3QCHRH0Kmeh87YPm5Q\$9S+jf+xzw2Hicj6nkWltvaaaXX3dQIxAFwCfFa9o38A');" | yarn workspace @affine/server prisma db execute --stdin \ No newline at end of file diff --git a/.devcontainer/setup-user.sh b/.devcontainer/setup-user.sh index 1171f79d4..21fd1c7cb 100755 --- a/.devcontainer/setup-user.sh +++ b/.devcontainer/setup-user.sh @@ -1,7 +1,9 @@ +set -e + if [ -v GRAPHITE_TOKEN ];then gt auth --token $GRAPHITE_TOKEN fi -git fetch +git fetch origin canary:canary --depth=1 git branch canary -t origin/canary gt init --trunk canary