Skip to content

Commit

Permalink
Merge pull request #36 from creampxxz/feature/app
Browse files Browse the repository at this point in the history
refactor: App dupplicate
  • Loading branch information
sikiryl authored Mar 31, 2022
2 parents 6dfb8df + 801b2d1 commit f444716
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
4 changes: 1 addition & 3 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { App } from "cdk8s";
import * as log4js from "log4js";
import * as Minimist from "minimist";
import { CommandManager } from './src/managers/commandManager';
Expand Down Expand Up @@ -38,6 +37,5 @@ const logLevel = LogConfig.logLevel(args.v);
log.level = logLevel;

log.debug("App Creating...");
const app = new App();
const commandManager = new CommandManager(app, commandOption);
const commandManager = new CommandManager(commandOption);
commandManager.handle(args);
5 changes: 2 additions & 3 deletions src/managers/commandManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { App } from "cdk8s"
import * as log4js from "log4js";
import * as Minimist from "minimist";
import ILevisCommand from "../interfaces";
Expand All @@ -12,11 +11,11 @@ export class CommandManager {

private command?: ILevisCommand;

constructor(app: App, commandOption: string) {
constructor(commandOption: string) {
switch(commandOption) {
case LevisCommand.CREATE: {
log.debug("create command");
this.command = new CreateCommand(app);
this.command = new CreateCommand();
break;
}
case LevisCommand.VERSION.toLowerCase(): {
Expand Down
14 changes: 5 additions & 9 deletions src/services/createCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ const log = log4js.getLogger();
export class CreateCommand implements ILevisCommand {

private command!: Command;
private app: App;

constructor(app: App){
this.app = app;
}

init(args: Minimist.ParsedArgs): Command {
log.debug("CreateCommand");
Expand All @@ -41,10 +36,11 @@ export class CreateCommand implements ILevisCommand {

process(): void {
log.debug("process");
new MicroServiceChart(this.app, this.command);
const app = new App();
new MicroServiceChart(app, this.command);
// Activate CDK8S for generating yaml file
this.app.synth();
FileUtils.Move(Path.CURRENT_PATH, this.command.outputFilePath);
app.synth();
FileUtils.Move("./dist/levis.k8s.yaml", this.command.outputFilePath);
}

}
}

0 comments on commit f444716

Please sign in to comment.