chore: create default user for devcontainer (#5917)

## **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**
<table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement
</strong></td><td><table>
<tr>
  <td>
    <details>
      <summary><strong>build.sh</strong><dd><code>Add Default User Creation to Dev Container Build Script</code>&nbsp; &nbsp; </dd></summary>
<hr>

.devcontainer/build.sh

<li>Added command to create a default user with username and password <br>'affine'.<br> <li> Ensured database push command is followed by a newline.<br>

</details>

  </td>
  <td><a href="https:/toeverything/AFFiNE/pull/5917/files#diff-165b66803397b501866b23a0532418e9ad3eb2ab642274f9679383c76d18136f">+4/-1</a>&nbsp; &nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
      <summary><strong>setup-user.sh</strong><dd><code>Enhance User Setup Script with Error Handling and Specific Git Fetch</code></dd></summary>
<hr>

.devcontainer/setup-user.sh

<li>Introduced error handling with 'set -e' to stop on first error.<br> <li> Modified 'git fetch' to specifically fetch 'canary' branch from <br>'origin' with depth of 1.<br>

</details>

  </td>
  <td><a href="https:/toeverything/AFFiNE/pull/5917/files#diff-8c5e76719e2ff0a3bf2b59d108dc9cf88bdae00c317728454cfa5108f2fc76af">+3/-1</a>&nbsp; &nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

>  **PR-Agent usage**:
>Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions
This commit is contained in:
EYHN 2024-02-27 03:32:03 +00:00
parent 2295685590
commit 0dabb08217
No known key found for this signature in database
GPG Key ID: 46C9E26A75AB276C
2 changed files with 7 additions and 2 deletions

View File

@ -12,4 +12,7 @@ yarn install
yarn workspace @affine/storage build
# Create database
yarn workspace @affine/server prisma db push
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

View File

@ -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