Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion cli/src/main/java/ca/weblite/jdeploy/DIContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,33 @@
import ca.weblite.jdeploy.openai.di.OpenAiModule;
import org.codejargon.feather.Feather;

import java.util.Arrays;

public class DIContext {

private final Feather feather = Feather.with(new JDeployModule(), new OpenAiModule(), new JDeployCliModule());
private final Feather feather;

private static DIContext instance;

public DIContext(Object ...modules) {
java.util.List<Object> args = new java.util.ArrayList<Object>();
args.add(new JDeployModule());
args.add(new OpenAiModule());
args.add(new JDeployCliModule());
args.addAll(Arrays.asList(modules));
feather = Feather.with(args);
}

public <T> T getInstance(Class<T> clazz) {
return feather.instance(clazz);
}

public static void initialize(Object ...modules) {
synchronized (DIContext.class) {
instance = new DIContext(modules);
}
}

public static DIContext getInstance() {
if (instance == null) {
synchronized (DIContext.class) {
Expand All @@ -27,4 +44,8 @@ public static DIContext getInstance() {
return instance;

}

public static <T> T get(Class<T> clazz) {
return getInstance().getInstance(clazz);
}
}
1 change: 0 additions & 1 deletion cli/src/main/java/ca/weblite/jdeploy/JDeploy.java
Original file line number Diff line number Diff line change
Expand Up @@ -2538,7 +2538,6 @@ private void _run() {
*/
public static void main(String[] args) {
try {
Feather feather = Feather.with(new JDeployModule());
JDeploy prog = new JDeploy(new File(".").getAbsoluteFile());
if (args.length > 0 && "generate".equals(args[0])) {
String[] generateArgs = new String[args.length-1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ public File getExtensionTemplate(String name) throws Exception {
return f;
}

public File[] getProjectTemplates() {
return getProjectsDir().listFiles();
}

public boolean isCatalogInitialized() {
return new File(localPath).exists();
}

private File getProjectsDir() {
return new File(localPath, "projects");
}
Expand Down
Loading