feat: Convert cli files to JS

This commit is contained in:
Faruk AYDIN
2024-01-08 17:08:20 +01:00
parent 8e4935409f
commit 34b115c694
4 changed files with 13 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
import { readFileSync } from 'fs';
import { Command, Flags } from '@oclif/core';
import * as dotenv from 'dotenv';
import process from 'process';
export default class StartWorker extends Command {
static description = 'Run automatisch worker';
@@ -13,7 +14,7 @@ export default class StartWorker extends Command {
'env-file': Flags.string(),
};
async prepareEnvVars(): Promise<void> {
async prepareEnvVars() {
const { flags } = await this.parse(StartWorker);
if (flags['env-file']) {
@@ -37,11 +38,11 @@ export default class StartWorker extends Command {
delete process.env.SERVE_WEB_APP_SEPARATELY;
}
async runWorker(): Promise<void> {
async runWorker() {
await import('@automatisch/backend/worker');
}
async run(): Promise<void> {
async run() {
await this.prepareEnvVars();
await this.runWorker();

View File

@@ -1,6 +1,7 @@
import { readFileSync } from 'fs';
import { Command, Flags } from '@oclif/core';
import * as dotenv from 'dotenv';
import process from 'process';
export default class Start extends Command {
static description = 'Run automatisch';
@@ -17,7 +18,7 @@ export default class Start extends Command {
return process.env.APP_ENV === 'production';
}
async prepareEnvVars(): Promise<void> {
async prepareEnvVars() {
const { flags } = await this.parse(Start);
if (flags['env-file']) {
@@ -41,7 +42,7 @@ export default class Start extends Command {
delete process.env.SERVE_WEB_APP_SEPARATELY;
}
async createDatabaseAndUser(): Promise<void> {
async createDatabaseAndUser() {
const utils = await import('@automatisch/backend/database-utils');
await utils.createDatabaseAndUser(
@@ -50,7 +51,7 @@ export default class Start extends Command {
);
}
async runMigrationsIfNeeded(): Promise<void> {
async runMigrationsIfNeeded() {
const { logger } = await import('@automatisch/backend/logger');
const database = await import('@automatisch/backend/database');
const migrator = database.client.migrate;
@@ -69,17 +70,17 @@ export default class Start extends Command {
}
}
async seedUser(): Promise<void> {
async seedUser() {
const utils = await import('@automatisch/backend/database-utils');
await utils.createUser();
}
async runApp(): Promise<void> {
async runApp() {
await import('@automatisch/backend/server');
}
async run(): Promise<void> {
async run() {
await this.prepareEnvVars();
if (!this.isProduction) {

View File

@@ -1,11 +1,13 @@
{
"compilerOptions": {
"declaration": true,
"allowJs": true,
"esModuleInterop": true,
"importHelpers": true,
"lib": ["es2021"],
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": false,
"outDir": "dist",
"rootDir": "src",
"skipLibCheck": true,