Skip to content

Commit

Permalink
Remove database choice from create-app command
Browse files Browse the repository at this point in the history
Signed-off-by: Johan Haals <johan.haals@gmail.com>
  • Loading branch information
jhaals committed Apr 26, 2022
1 parent 08e7fc5 commit 00fa0da
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 33 deletions.
9 changes: 9 additions & 0 deletions .changeset/smart-ghosts-search.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ site

# Local configuration files
*.local.yaml
!packages/create-app/templates/default-app/app-config.local.yaml

# Sensitive credentials
*-credentials.yaml
Expand Down
8 changes: 0 additions & 8 deletions packages/create-app/src/createApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,7 @@ export default async (opts: OptionValues): Promise<void> => {
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Backstage override configuration for your local development environment
Original file line number Diff line number Diff line change
Expand Up @@ -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: <file-path>/ca/server.crt
20 changes: 2 additions & 18 deletions packages/create-app/templates/default-app/app-config.yaml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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: <file-path>/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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 00fa0da

Please sign in to comment.