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

View File

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

View File

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