Skip to content

Commit

Permalink
chore(cli): rename seeder file (#52)
Browse files Browse the repository at this point in the history
* chore(cli): rename seeder file

* chore(cli): fix eof new line
  • Loading branch information
nnorbert authored Jun 28, 2024
1 parent 73c5e48 commit 5663928
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 46 deletions.
6 changes: 3 additions & 3 deletions .gitleaksignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/src/packages/connectors/connector-saml/README.md:private-key:101
/src/packages/cli/src/commands/database/ogcio/ogcio-seeder.json:generic-api-key:37
/src/packages/cli/src/commands/database/ogcio/ogcio-seeder.json:generic-api-key:46
/src/packages/cli/src/commands/database/ogcio/ogcio-seeder.json:generic-api-key:157
/src/packages/cli/src/commands/database/ogcio/ogcio-seeder-local.json:generic-api-key:37
/src/packages/cli/src/commands/database/ogcio/ogcio-seeder-local.json:generic-api-key:46
/src/packages/cli/src/commands/database/ogcio/ogcio-seeder-local.json:generic-api-key:157
6 changes: 3 additions & 3 deletions README.OGCIO.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ USER_DEFAULT_ORGANIZATION_ROLE_NAMES=OGCIO Employee, OGCIO Manager

3. After the installation, you can start seeding the database. You have to seed in two steps:
- seed Logto's database: `pnpm cli db seed`
- seed custom OGCIO data: `npm run cli db ogcio -- --seeder-filepath="./packages/cli/src/commands/database/ogcio/ogcio-seeder.json"`
- seed custom OGCIO data: `npm run cli db ogcio -- --seeder-filepath="./packages/cli/src/commands/database/ogcio/ogcio-seeder-local.json"`

3.5. Database alteration

Expand Down Expand Up @@ -98,7 +98,7 @@ After installing and seeding the database, you must create a default admin user.

## Custom seeder

We made a custom seeder to ensure the required configuration for OGCIO Building Block integration exists right after the installation. The seeder also makes configuring the deployed Logto instance easy via a CI pipeline. The seeder is located in `packages/cli/src/commands/database/ogcio/`. The configuration for the local dev environment is inside `packages/cli/src/commands/database/ogcio/ogcio-seeder.json`.
We made a custom seeder to ensure the required configuration for OGCIO Building Block integration exists right after the installation. The seeder also makes configuring the deployed Logto instance easy via a CI pipeline. The seeder is located in `packages/cli/src/commands/database/ogcio/`. The configuration for the local dev environment is inside `packages/cli/src/commands/database/ogcio/ogcio-seeder-local.json`.

Each type of configuration has its own dedicated file, which serves as a repository of knowledge about the structure of the configuration and how it should be inserted into the database. This approach ensures a systematic and organized management of the database configuration.

Expand All @@ -112,4 +112,4 @@ This command can take a parameter to specify the input data file, called `seeder

Usage: `npm run cli db ogcio -- --seeder-filepath="DATA_FILE_PATH"`

To seed the default data for local dev environments, run `npm run cli db ogcio -- --seeder-filepath="./packages/cli/src/commands/database/ogcio/ogcio-seeder.json"`.
To seed the default data for local dev environments, run `npm run cli db ogcio -- --seeder-filepath="./packages/cli/src/commands/database/ogcio/ogcio-seeder-local.json"`.
2 changes: 1 addition & 1 deletion docker-compose-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
[
"sh",
"-c",
"npm run cli db seed -- --swe && npm run cli db alteration deploy latest && npm run cli db ogcio -- --seeder-filepath=\"/etc/logto/packages/cli/src/commands/database/ogcio/ogcio-seeder.json\" && npm start"
"npm run cli db seed -- --swe && npm run cli db alteration deploy latest && npm run cli db ogcio -- --seeder-filepath=\"/etc/logto/packages/cli/src/commands/database/ogcio/ogcio-seeder-local.json\" && npm start"
]
ports:
- 3301:3301
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/database/ogcio/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { consoleLog } from '../../../utils.js';
import { setTenantSeederData, type OgcioTenantSeeder } from './ogcio-seeder.js';
import { seedOgcio } from './ogcio.js';

const DEFAULT_SEEDER_FILE = './src/commands/database/ogcio/ogcio-seeder.json';
const DEFAULT_SEEDER_FILE = './src/commands/database/ogcio/ogcio-seeder-local.json';

const interpolateString = (content: string): string => {
const regExp = /<\w+>/g;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"default": {
"organizations": [
{
"name": "OGCIO",
"description": "OGCIO Organization",
"name": "OGCIO Seeded Org",
"description": "Organization created through seeder",
"id": "ogcio"
}
],
Expand Down Expand Up @@ -32,31 +32,31 @@
"name": "Payments Building Block",
"description": "Payments App of Life Events",
"type": "Traditional",
"redirect_uri": "<SEEDER_PAYMENTS_APP_REDIRECT_URI>",
"logout_redirect_uri": "<SEEDER_PAYMENTS_APP_LOGOUT_REDIRECT_URI>",
"secret": "<SEEDER_PAYMENTS_APP_SECRET>",
"id": "r5f56tpkytpqyyshiutd2"
"redirect_uri": "http://localhost:3001/callback",
"logout_redirect_uri": "http://localhost:3001",
"secret": "bgHz4Ouv2lxXCdc6s6s4IUoNpFAklC15",
"id": "2xz6sbi8ch01uhjt1oq8r"
},
{
"name": "Messaging Building Block",
"description": "Messaging App of Life Events",
"type": "Traditional",
"redirect_uri": "<SEEDER_MESSAGING_APP_REDIRECT_URI>",
"logout_redirect_uri": "<SEEDER_MESSAGING_APP_LOGOUT_REDIRECT_URI>",
"secret": "<SEEDER_MESSAGING_APP_SECRET>",
"id": "1lvmteh2ao3xrswyq7j3e"
"redirect_uri": "http://localhost:3002/callback",
"logout_redirect_uri": "http://localhost:3002",
"secret": "Y3nBMm8Hs3Ugcl4596w5ewgOosvwX4im",
"id": "4695d8onfb9f3bv18phtq"
}
],
"resources": [
{
"id": "payments-api",
"name": "Payments Building Block API",
"indicator": "<SEEDER_PAYMENTS_API_INDICATOR>"
"indicator": "http://localhost:8001/"
},
{
"id": "messaging-api",
"name": "Messaging Building Block API",
"indicator": "<SEEDER_MESSAGING_API_INDICATOR>"
"indicator": "http://localhost:8002/"
}
],
"resource_permissions": [
Expand Down Expand Up @@ -94,13 +94,13 @@
"connector_id": "mygovid",
"config": {
"scope": "openid profile email",
"clientId": "<SEEDER_MYGOVID_CONNECTOR_CLIENT_ID>",
"clientSecret": "<SEEDER_MYGOVID_CONNECTOR_CLIENT_SECRET>",
"tokenEndpoint": "<SEEDER_MYGOVID_CONNECTOR_TOKEN_ENDPOINT>",
"authorizationEndpoint": "<SEEDER_MYGOVID_CONNECTOR_AUTHORIZATION_ENDPOINT>",
"clientId": "mock_client_id",
"clientSecret": "mock_client_secret",
"tokenEndpoint": "http://localhost:3005/logto/mock/token",
"authorizationEndpoint": "http://localhost:3005/logto/mock/auth",
"tokenEndpointAuthMethod": "client_secret_post",
"idTokenVerificationConfig": {
"jwksUri": "<SEEDER_MYGOVID_CONNECTOR_JWS_URI>"
"jwksUri": "http://localhost:3005/logto/mock/keys"
},
"clientSecretJwtSigningAlgorithm": "HS256"
},
Expand Down Expand Up @@ -152,9 +152,9 @@
"PostSignIn"
],
"config": {
"url": "<SEEDER_WEBHOOK_LOGIN_URL>"
"url": "http://localhost:8003/user-login-wh"
},
"signing_key": "<SEEDER_WEBHOOK_SIGNING_KEY>",
"signing_key": "xpWX3WIkPkSA5A0UzLMfNOuTl1qEnbkg",
"enabled": true
}
]
Expand Down
38 changes: 19 additions & 19 deletions packages/cli/src/commands/database/ogcio/ogcio-seeder.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"default": {
"organizations": [
{
"name": "OGCIO Seeded Org",
"description": "Organization created through seeder",
"name": "OGCIO",
"description": "OGCIO Organization",
"id": "ogcio"
}
],
Expand Down Expand Up @@ -32,31 +32,31 @@
"name": "Payments Building Block",
"description": "Payments App of Life Events",
"type": "Traditional",
"redirect_uri": "http://localhost:3001/callback",
"logout_redirect_uri": "http://localhost:3001",
"secret": "bgHz4Ouv2lxXCdc6s6s4IUoNpFAklC15",
"id": "2xz6sbi8ch01uhjt1oq8r"
"redirect_uri": "<SEEDER_PAYMENTS_APP_REDIRECT_URI>",
"logout_redirect_uri": "<SEEDER_PAYMENTS_APP_LOGOUT_REDIRECT_URI>",
"secret": "<SEEDER_PAYMENTS_APP_SECRET>",
"id": "r5f56tpkytpqyyshiutd2"
},
{
"name": "Messaging Building Block",
"description": "Messaging App of Life Events",
"type": "Traditional",
"redirect_uri": "http://localhost:3002/callback",
"logout_redirect_uri": "http://localhost:3002",
"secret": "Y3nBMm8Hs3Ugcl4596w5ewgOosvwX4im",
"id": "4695d8onfb9f3bv18phtq"
"redirect_uri": "<SEEDER_MESSAGING_APP_REDIRECT_URI>",
"logout_redirect_uri": "<SEEDER_MESSAGING_APP_LOGOUT_REDIRECT_URI>",
"secret": "<SEEDER_MESSAGING_APP_SECRET>",
"id": "1lvmteh2ao3xrswyq7j3e"
}
],
"resources": [
{
"id": "payments-api",
"name": "Payments Building Block API",
"indicator": "http://localhost:8001/"
"indicator": "<SEEDER_PAYMENTS_API_INDICATOR>"
},
{
"id": "messaging-api",
"name": "Messaging Building Block API",
"indicator": "http://localhost:8002/"
"indicator": "<SEEDER_MESSAGING_API_INDICATOR>"
}
],
"resource_permissions": [
Expand Down Expand Up @@ -94,13 +94,13 @@
"connector_id": "mygovid",
"config": {
"scope": "openid profile email",
"clientId": "mock_client_id",
"clientSecret": "mock_client_secret",
"tokenEndpoint": "http://localhost:3005/logto/mock/token",
"authorizationEndpoint": "http://localhost:3005/logto/mock/auth",
"clientId": "<SEEDER_MYGOVID_CONNECTOR_CLIENT_ID>",
"clientSecret": "<SEEDER_MYGOVID_CONNECTOR_CLIENT_SECRET>",
"tokenEndpoint": "<SEEDER_MYGOVID_CONNECTOR_TOKEN_ENDPOINT>",
"authorizationEndpoint": "<SEEDER_MYGOVID_CONNECTOR_AUTHORIZATION_ENDPOINT>",
"tokenEndpointAuthMethod": "client_secret_post",
"idTokenVerificationConfig": {
"jwksUri": "http://localhost:3005/logto/mock/keys"
"jwksUri": "<SEEDER_MYGOVID_CONNECTOR_JWS_URI>"
},
"clientSecretJwtSigningAlgorithm": "HS256"
},
Expand Down Expand Up @@ -152,9 +152,9 @@
"PostSignIn"
],
"config": {
"url": "http://localhost:8003/user-login-wh"
"url": "<SEEDER_WEBHOOK_LOGIN_URL>"
},
"signing_key": "xpWX3WIkPkSA5A0UzLMfNOuTl1qEnbkg",
"signing_key": "<SEEDER_WEBHOOK_SIGNING_KEY>",
"enabled": true
}
]
Expand Down

0 comments on commit 5663928

Please sign in to comment.