authgear / authgear-server

Open source alternative to Auth0 / Firebase Auth
https://www.authgear.com
Apache License 2.0
81 stars 37 forks source link

Add script that set existing logo heights to 40px if not customized #4776

Open pkong-ds opened 3 days ago

pkong-ds commented 3 days ago

ref DEV-2126

Preview - actual test

https://github.com/user-attachments/assets/1e545b07-a299-4a15-a30f-b109d08ad4d7

Preview - dry-run

$ go run ./cmd/portal internal breaking-change migrate-resources migrate-set-default-logo-height --database-url "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" --database-schema public
2024/09/26 17:37:54 maxprocs: Leaving GOMAXPROCS=8: CPU quota undefined
2024/09/26 17:37:54 Skipping app (cactus-4guctg) because it does not have logo set
2024/09/26 17:37:54 converting resources app_id: cactus-4guctg, updated: false
2024/09/26 17:37:54 Converting app (accounts)
2024/09/26 17:37:54 Skipping dark theme css of app (accounts) because it already has logo height set
2024/09/26 17:37:54 Before light-theme.css updated:
2024/09/26 17:37:54 static_2f_authgear-authflowv_32_-light-theme.css:
:root {
    --layout__bg-color: #F0FFFF;
    --alignment-card: center;
    --primary-btn__bg-color: #176df3;
    --primary-btn__bg-color--active: #1151b8;
    --primary-btn__bg-color--hover: #1151b8;
    --primary-btn__text-color: #ffffff;
    --primary-btn__border-radius: 0.875em;
    --secondary-btn__border-radius: 0.875em;
    --input__border-radius: 0.875em;
    --phone-input__trigger-border-radius: 0.875em
}
2024/09/26 17:37:54 After light-theme.css updated:
2024/09/26 17:37:54 static_2f_authgear-authflowv_32_-light-theme.css:
:root {
  --layout__bg-color: #F0FFFF;
  --alignment-card: center;
  --primary-btn__bg-color: #176df3;
  --primary-btn__bg-color--active: #1151b8;
  --primary-btn__bg-color--hover: #1151b8;
  --primary-btn__text-color: #ffffff;
  --primary-btn__border-radius: 0.875em;
  --secondary-btn__border-radius: 0.875em;
  --input__border-radius: 0.875em;
  --phone-input__trigger-border-radius: 0.875em;
  --brand-logo__height: 40px;
}

2024/09/26 17:37:54 converting resources app_id: accounts, updated: true
2024/09/26 17:37:54 diff of authgear.yaml: accounts
2024/09/26 17:37:54
2024/09/26 17:37:54 dry run: number of apps to update: 1

Preview - dry-run=false (update on first run)

$ go run ./cmd/portal internal breaking-change migrate-resources migrate-set-default-logo-height --database-url "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" --database-schema public --dry-run=false
2024/09/26 17:38:31 maxprocs: Leaving GOMAXPROCS=8: CPU quota undefined
2024/09/26 17:38:31 Skipping app (cactus-4guctg) because it does not have logo set
2024/09/26 17:38:31 converting resources app_id: cactus-4guctg, updated: false
2024/09/26 17:38:31 Skipping dark theme css of app (accounts) because it already has logo height set
2024/09/26 17:38:31 converting resources app_id: accounts, updated: true
2024/09/26 17:38:31 updated resources to db: accounts
2024/09/26 17:38:31 updated apps count: 1

Preview - dry-run=false (should have 0 apps updated on 2nd run)

$ go run ./cmd/portal internal breaking-change migrate-resources migrate-set-default-logo-height --database-url "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" --database-schema public --dry-run=false
2024/09/26 17:39:07 maxprocs: Leaving GOMAXPROCS=8: CPU quota undefined
2024/09/26 17:39:07 Skipping app (cactus-4guctg) because it does not have logo set
2024/09/26 17:39:07 converting resources app_id: cactus-4guctg, updated: false
2024/09/26 17:39:07 Skipping light theme css of app (accounts) because it already has logo height set
2024/09/26 17:39:07 Skipping dark theme css of app (accounts) because it already has logo height set
2024/09/26 17:39:07 converting resources app_id: accounts, updated: false
2024/09/26 17:39:07 updated apps count: 0
pkong-ds commented 3 days ago

Just realized I missed the case where the project does not have customized css at all. In this case, I should create the css file for the project

pkong-ds commented 3 days ago

@louischan-oursky Ready for review, thanks 🙏