chore: introduce docker compose

This commit is contained in:
Ali BARIN
2022-08-26 11:35:51 +02:00
parent 6271cedc25
commit e997aa6c81
10 changed files with 28 additions and 14 deletions

1
packages/backend/database-utils.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist/bin/database/utils';

View File

@@ -0,0 +1,2 @@
/* eslint-disable */
module.exports = require('./dist/bin/database/utils');

View File

@@ -1,2 +1 @@
export * as utils from './dist/bin/database/utils';
export * as database from './dist/src/config/database';
export * from './dist/src/config/database';

View File

@@ -1,3 +1,2 @@
/* eslint-disable */
module.exports.utils = require('./dist/bin/database/utils');
module.exports.database = require('./dist/src/config/database');
module.exports = require('./dist/src/config/database');

View File

@@ -16,7 +16,8 @@
"db:migration:create": "knex migrate:make",
"db:rollback": "knex migrate:rollback",
"db:migrate": "knex migrate:latest",
"copy-statics": "copyfiles src/**/*.{graphql,json,svg} dist"
"copy-statics": "copyfiles src/**/*.{graphql,json,svg} dist",
"prepack": "yarn build"
},
"dependencies": {
"@automatisch/web": "0.1.0",
@@ -75,6 +76,7 @@
"test": "__tests__"
},
"files": [
"dist",
"bin",
"src",
"server.js",
@@ -82,7 +84,9 @@
"logger.js",
"logger.d.ts",
"database.js",
"database.d.ts"
"database.d.ts",
"database-utils.js",
"database-utils.d.ts"
],
"repository": {
"type": "git",

View File

@@ -13,6 +13,10 @@ export default class Start extends Command {
'env-file': Flags.string(),
}
get isProduction() {
return process.env.APP_ENV === 'production';
}
async prepareEnvVars(): Promise<void> {
const { flags } = await this.parse(Start);
@@ -38,7 +42,7 @@ export default class Start extends Command {
}
async createDatabaseAndUser(): Promise<void> {
const { utils } = await import('@automatisch/backend/database');
const utils = await import('@automatisch/backend/database-utils');
await utils.createDatabaseAndUser(
process.env.POSTGRES_DATABASE,
@@ -48,7 +52,7 @@ export default class Start extends Command {
async runMigrationsIfNeeded(): Promise<void> {
const { logger } = await import('@automatisch/backend/logger');
const { database } = await import('@automatisch/backend/database');
const database = await import('@automatisch/backend/database');
const migrator = database.client.migrate;
const [, pendingMigrations] = await migrator.list();
@@ -66,7 +70,7 @@ export default class Start extends Command {
}
async seedUser(): Promise<void> {
const { utils } = await import('@automatisch/backend/database');
const utils = await import('@automatisch/backend/database-utils');
await utils.createUser();
}
@@ -78,7 +82,9 @@ export default class Start extends Command {
async run(): Promise<void> {
await this.prepareEnvVars();
await this.createDatabaseAndUser();
if (!this.isProduction) {
await this.createDatabaseAndUser();
}
await this.runMigrationsIfNeeded();

View File

@@ -2,6 +2,7 @@
"name": "@automatisch/docs",
"version": "0.1.0",
"description": "> TODO: description",
"private": true,
"scripts": {
"dev": "vitepress dev pages --port 3002",
"build": "vitepress build pages",

View File

@@ -5,7 +5,6 @@
"homepage": "https://github.com/automatisch/automatisch",
"types": "./index.d.ts",
"scripts": {},
"dependencies": {},
"typeScriptVersion": "4.1",
"repository": {
"type": "git",

View File

@@ -47,8 +47,12 @@
"build:watch": "yarn nodemon --exec react-scripts build --watch 'src/**/*.ts' --watch 'public/**/*' --ext ts,html",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint . --ignore-path ../../.eslintignore"
"lint": "eslint . --ignore-path ../../.eslintignore",
"prepack": "REACT_APP_GRAPHQL_URL=/graphql yarn build"
},
"files": [
"/build"
],
"contributors": [
{
"name": "automatisch contributors",

View File

@@ -47,8 +47,7 @@ const processOpenWithPopup = (step: IAuthenticationStep, variables: IJSONObject)
popup?.focus();
const messageHandler = async (event: MessageEvent) => {
// check origin and data.source to trust the event
if (event.origin !== appConfig.baseUrl || event.data.source !== 'automatisch') {
if (event.data.source !== 'automatisch') {
return;
}