Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve start-databse scripts exit and messages #1816

Merged
merged 2 commits into from
Apr 7, 2024

Conversation

kasbah
Copy link
Contributor

@kasbah kasbah commented Apr 5, 2024

✅ Checklist

  • I have followed every step in the contributing guide (updated 2022-10-06).
  • The PR title follows the convention we established conventional-commit
  • I performed a functional test on my final commit

Changelog

  • Improve the exit status and messages of the docker start-database scripts. It could fail and still say "Database container was successfully created".
  • Run shellcheck on the scripts and accepted the minor suggestions
$ shellcheck postgres.sh 

In postgres.sh line 15:
  echo "Docker is not installed. Please install docker and try again.\nDocker install guide: https://docs.docker.com/engine/install/"
       ^-- SC2028 (info): echo may not expand escape sequences. Use printf.


In postgres.sh line 27:
source .env
       ^--^ SC1091 (info): Not following: .env was not specified as input (see shellcheck -x).


In postgres.sh line 29:
DB_PASSWORD=$(echo $DATABASE_URL | awk -F':' '{print $3}' | awk -F'@' '{print $1}')
                   ^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
DB_PASSWORD=$(echo "$DATABASE_URL" | awk -F':' '{print $3}' | awk -F'@' '{print $1}')


In postgres.sh line 43:
docker run --name $DB_CONTAINER_NAME -e POSTGRES_PASSWORD=$DB_PASSWORD -e POSTGRES_DB=project1 -d -p 5432:5432 docker.io/postgres
                                                          ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
docker run --name $DB_CONTAINER_NAME -e POSTGRES_PASSWORD="$DB_PASSWORD" -e POSTGRES_DB=project1 -d -p 5432:5432 docker.io/postgres

For more information:
  https://www.shellcheck.net/wiki/SC1091 -- Not following: .env was not speci...
  https://www.shellcheck.net/wiki/SC2028 -- echo may not expand escape sequen...
  https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
  

Copy link

changeset-bot bot commented Apr 5, 2024

⚠️ No Changeset found

Latest commit: c800237

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Apr 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
create-t3-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 5, 2024 0:26am

Copy link

vercel bot commented Apr 5, 2024

@kasbah is attempting to deploy a commit to the t3-oss Team on Vercel.

A member of the Team first needs to authorize it.

-e MYSQL_ROOT_PASSWORD="$DB_PASSWORD" \
-e MYSQL_DATABASE=project1 \
-p 3306:3306 \
docker.io/mysql && echo "Database container '$DB_CONTAINER_NAME' was successfully created"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why && here and not just run it on it's own line?

Copy link
Contributor Author

@kasbah kasbah Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's so that it doesn't lie and print "successfully created" if the docker command fails. You could put it on its own line and check the exit status or set -e for the entire script but this actually seems simpler and clearer.

@juliusmarminge juliusmarminge merged commit 8ff2e5b into t3-oss:main Apr 7, 2024
265 of 267 checks passed
devvianto605 pushed a commit to devvianto605/create-devviantex-nextjs-app that referenced this pull request Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📌 area: cli Relates to the CLI 📌 area: t3-app Relates to the generated T3 App
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants