From 00fa0dada002ee96b035600322ac0d0e9f0bf61d Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 20 Apr 2022 15:08:20 +0200 Subject: [PATCH] Remove database choice from `create-app` command Signed-off-by: Johan Haals --- .changeset/smart-ghosts-search.md | 9 +++++++++ .gitignore | 1 + packages/create-app/src/createApp.ts | 8 -------- .../default-app/app-config.local.yaml | 1 + .../default-app/app-config.production.yaml | 15 ++++++++++++++ .../templates/default-app/app-config.yaml.hbs | 20 ++----------------- .../packages/backend/package.json.hbs | 8 +------- 7 files changed, 29 insertions(+), 33 deletions(-) create mode 100644 .changeset/smart-ghosts-search.md create mode 100644 packages/create-app/templates/default-app/app-config.local.yaml diff --git a/.changeset/smart-ghosts-search.md b/.changeset/smart-ghosts-search.md new file mode 100644 index 0000000000..5d8b3676cb --- /dev/null +++ b/.changeset/smart-ghosts-search.md @@ -0,0 +1,9 @@ +--- +'@backstage/create-app': patch +--- + +Removed the database choice from the `create-app` command. + +This reduces the step from development to production by always installing the dependencies and templating the production configuration in `app-config.production.yaml`. + +Added `app-config.local.yaml` to allow for local configuration overrides. diff --git a/.gitignore b/.gitignore index 60d0d6da3b..a54955ac73 100644 --- a/.gitignore +++ b/.gitignore @@ -130,6 +130,7 @@ site # Local configuration files *.local.yaml +!packages/create-app/templates/default-app/app-config.local.yaml # Sensitive credentials *-credentials.yaml diff --git a/packages/create-app/src/createApp.ts b/packages/create-app/src/createApp.ts index 83584445b0..824d1d967e 100644 --- a/packages/create-app/src/createApp.ts +++ b/packages/create-app/src/createApp.ts @@ -50,15 +50,7 @@ export default async (opts: OptionValues): Promise => { return true; }, }, - { - type: 'list', - name: 'dbType', - message: chalk.blue('Select database for the backend [required]'), - choices: ['SQLite', 'PostgreSQL'], - }, ]); - answers.dbTypePG = answers.dbType === 'PostgreSQL'; - answers.dbTypeSqlite = answers.dbType === 'SQLite'; const templateDir = paths.resolveOwn('templates/default-app'); const tempDir = resolvePath(os.tmpdir(), answers.name); diff --git a/packages/create-app/templates/default-app/app-config.local.yaml b/packages/create-app/templates/default-app/app-config.local.yaml new file mode 100644 index 0000000000..976293b546 --- /dev/null +++ b/packages/create-app/templates/default-app/app-config.local.yaml @@ -0,0 +1 @@ +# Backstage override configuration for your local development environment diff --git a/packages/create-app/templates/default-app/app-config.production.yaml b/packages/create-app/templates/default-app/app-config.production.yaml index c180bbfdec..c6ae2c036b 100644 --- a/packages/create-app/templates/default-app/app-config.production.yaml +++ b/packages/create-app/templates/default-app/app-config.production.yaml @@ -17,3 +17,18 @@ backend: # backend will bind on the interface that corresponds to the backend.baseUrl # hostname. host: 0.0.0.0 + +# config options: https://node-postgres.com/api/client +database: + client: pg + connection: + host: ${POSTGRES_HOST} + port: ${POSTGRES_PORT} + user: ${POSTGRES_USER} + password: ${POSTGRES_PASSWORD} + # https://node-postgres.com/features/ssl + # you can set the sslmode configuration option via the `PGSSLMODE` environment variable + # see https://www.postgresql.org/docs/current/libpq-ssl.html Table 33.1. SSL Mode Descriptions (e.g. require) + # ssl: + # ca: # if you have a CA file and want to verify it you can uncomment this section + # $file: /ca/server.crt diff --git a/packages/create-app/templates/default-app/app-config.yaml.hbs b/packages/create-app/templates/default-app/app-config.yaml.hbs index e274ffeaf2..2bf366d756 100644 --- a/packages/create-app/templates/default-app/app-config.yaml.hbs +++ b/packages/create-app/templates/default-app/app-config.yaml.hbs @@ -26,27 +26,11 @@ backend: origin: http://localhost:3000 methods: [GET, POST, PUT, DELETE] credentials: true - {{#if dbTypeSqlite}} + # This is for local developement only, it is not recommended to use this in production + # The production database configuration is stored in app-config.production.yaml database: client: better-sqlite3 connection: ':memory:' - {{/if}} - {{#if dbTypePG}} - # config options: https://node-postgres.com/api/client - database: - client: pg - connection: - host: ${POSTGRES_HOST} - port: ${POSTGRES_PORT} - user: ${POSTGRES_USER} - password: ${POSTGRES_PASSWORD} - # https://node-postgres.com/features/ssl - # you can set the sslmode configuration option via the `PGSSLMODE` environment variable - # see https://www.postgresql.org/docs/current/libpq-ssl.html Table 33.1. SSL Mode Descriptions (e.g. require) - # ssl: - # ca: # if you have a CA file and want to verify it you can uncomment this section - # $file: /ca/server.crt - {{/if}} cache: store: memory # workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir diff --git a/packages/create-app/templates/default-app/packages/backend/package.json.hbs b/packages/create-app/templates/default-app/packages/backend/package.json.hbs index 939b13bf86..acfd465b67 100644 --- a/packages/create-app/templates/default-app/packages/backend/package.json.hbs +++ b/packages/create-app/templates/default-app/packages/backend/package.json.hbs @@ -30,24 +30,18 @@ "@backstage/plugin-proxy-backend": "^{{version '@backstage/plugin-proxy-backend'}}", "@backstage/plugin-scaffolder-backend": "^{{version '@backstage/plugin-scaffolder-backend'}}", "@backstage/plugin-search-backend": "^{{version '@backstage/plugin-search-backend'}}", - {{#if dbTypePG}} "@backstage/plugin-search-backend-module-pg": "^{{version '@backstage/plugin-search-backend-module-pg'}}", - {{/if}} "@backstage/plugin-search-backend-node": "^{{version '@backstage/plugin-search-backend-node'}}", "@backstage/plugin-techdocs-backend": "^{{version '@backstage/plugin-techdocs-backend'}}", "dockerode": "^3.3.1", "express": "^4.17.1", "express-promise-router": "^4.1.0", "luxon": "^2.0.2", - {{#if dbTypePG}} "pg": "^8.3.0", - {{/if}} - {{#if dbTypeSqlite}} - "better-sqlite3": "^7.5.0", - {{/if}} "winston": "^3.2.1" }, "devDependencies": { + "better-sqlite3": "^7.5.0", "@backstage/cli": "^{{version '@backstage/cli'}}", "@types/dockerode": "^3.3.0", "@types/express": "^4.17.6",